Modify player logic to use animation parameters
This commit is contained in:
@@ -33,7 +33,8 @@ public class Player : MonoBehaviour
|
|||||||
Jump();
|
Jump();
|
||||||
Run();
|
Run();
|
||||||
FlipSprite();
|
FlipSprite();
|
||||||
MarkAsRunning();
|
//MarkAsRunning();
|
||||||
|
HandleAnimations();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Jump()
|
private void Jump()
|
||||||
@@ -95,11 +96,18 @@ public class Player : MonoBehaviour
|
|||||||
{
|
{
|
||||||
if (Mathf.Abs(rigidBody.velocity.x) > Mathf.Epsilon)
|
if (Mathf.Abs(rigidBody.velocity.x) > Mathf.Epsilon)
|
||||||
{
|
{
|
||||||
//animator.SetBool("IsRunning", true);
|
animator.SetBool("IsRunning", true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//animator.SetBool("IsRunning", false);
|
animator.SetBool("IsRunning", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleAnimations()
|
||||||
|
{
|
||||||
|
animator.SetBool("IsRunning", Mathf.Abs(rigidBody.velocity.x) > float.Epsilon);
|
||||||
|
animator.SetBool("IsOnGround", IsPlayerOnGround());
|
||||||
|
animator.SetFloat("YVelocity", rigidBody.velocity.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user