I'm working on a mobile 3d game, i've shared a picture from my character's movement script, if you look at it you can see there is an "anim.SetInteger" for each input but the "condition" doen't change to "1" for every direction. If you guys know what do i need to do that, pls let me know.
Your else
statement only applies to your final if
statement. What's probably happening is that one of your first six if
statements is true, so then your Condition
animation parameter gets set to 1. But since your final if
statement if false, the else
block also gets executed, so Condition
gets set back to zero within the same game loop iteration.
Change all of your middle if
statements to else if
. It should be like this:
if (/* condition 1 */)
{
anim.SetInteger("Condition", 1);
// transform = ...
}
else if (/* condition 2 */)
{
anim.SetInteger("Condition", 1);
// transform = ...
}
else if (/* condition 3 */)
{
anim.SetInteger("Condition", 1);
// transform = ...
}
else
{
anim.SetInteger("Condition", 0);
horizontal = 0;
vertical = 0;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.