From 9c18c13e8d3b673b887b53a2dc4b96a6bf2cf88a Mon Sep 17 00:00:00 2001 From: Sweet Tini Date: Sat, 1 Feb 2020 11:51:23 -0500 Subject: [PATCH] Modify player logic to use animation parameters --- Assets/Scripts/Player.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 36cb290..0012385 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -33,7 +33,8 @@ public class Player : MonoBehaviour Jump(); Run(); FlipSprite(); - MarkAsRunning(); + //MarkAsRunning(); + HandleAnimations(); } private void Jump() @@ -95,11 +96,18 @@ public class Player : MonoBehaviour { if (Mathf.Abs(rigidBody.velocity.x) > Mathf.Epsilon) { - //animator.SetBool("IsRunning", true); + animator.SetBool("IsRunning", true); } 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); + } }