Hi there.
I finished the course, and was trying to implement more actions to this platformer tutorial.
in this code
private void Jump()
{
if (!myFeet.IsTouchingLayers(LayerMask.GetMask("Ground"))) { return; }
if (CrossPlatformInputManager.GetButtonDown("Jump"))
{
Vector2 jumpVelocityToAdd = new Vector2(0f, jumpSpeed);
myRigidBody.velocity += jumpVelocityToAdd;
}
}
I tried, to add a Jump Animation, when he is not touching the ground, (falling or jumping). I added the animation in the Animator, and transitions.
I added this, with no results
private void Jump()
{
if (!myFeet.IsTouchingLayers(LayerMask.GetMask("Ground"))) { return; }
if (CrossPlatformInputManager.GetButtonDown("Jump"))
{
bool playerHasVerticalSpeed = Mathf.Abs(myRigidBody.velocity.y) > Mathf.Epsilon;
myAnimator.SetBool("Jumping", playerHasVerticalSpeed);
Vector2 jumpVelocityToAdd = new Vector2(0f, jumpSpeed);
myRigidBody.velocity += jumpVelocityToAdd;
}
}
Sorry for my broken English.
What could be wrong?