if(MyRigidBody.velocity.x != 0)
{
MyAnimator.SetBool("IsRunning", true);
}
else
{
MyAnimator.SetBool("IsRunning", false);
}
4 Likes
Great job!
1 Like
This is great! We had the same thought! Only that because I’ve worked so much with bools (in javascript LOL) I approached with an even shorter solution (1 liner!):
playerAnimator.SetBool("isRunning", playerVelocity.x != 0);
The !=
operator is the “inequality” operator which returns a bool, and because it is a bool and we are comparing the X velocity to check if the player is moving or not, it is already returning the bool value we’re looking for, so we can set that value right away!
1 Like