diff --git a/Assets/Scripts/Player/PlayerMovement.cs b/Assets/Scripts/Player/PlayerMovement.cs index 75112bd1ebd416601b40b26d519d686c287a689f..3f60686397f3856a1d1914727ba58136f42d0b85 100644 --- a/Assets/Scripts/Player/PlayerMovement.cs +++ b/Assets/Scripts/Player/PlayerMovement.cs @@ -5,19 +5,31 @@ using UnityEngine; +public enum PlayerState +{ + walk, + interact +} + public class PlayerMovement : MonoBehaviour { public float speed; private Rigidbody2D myRigidbody; private Vector3 change; private Animator animator; + public PlayerState currentState; // Start is called before the first frame update void Start() { + currentState = PlayerState.walk; + animator = GetComponent<Animator>(); myRigidbody = GetComponent<Rigidbody2D>(); + animator.SetFloat("moveX", 0); + animator.SetFloat("moveY", -1); + } // Update is called once per frame @@ -28,7 +40,11 @@ public class PlayerMovement : MonoBehaviour change.x = Input.GetAxisRaw("Horizontal"); change.y = Input.GetAxisRaw("Vertical"); - UpdateAnimationAndMove(); + if(currentState == PlayerState.walk) + { + UpdateAnimationAndMove(); + } + Vector3 pos = Camera.main.WorldToViewportPoint(transform.position); pos.x = Mathf.Clamp01(pos.x); @@ -38,6 +54,7 @@ public class PlayerMovement : MonoBehaviour void MoveCharacter() { + change.Normalize(); myRigidbody.MovePosition(transform.position + change * speed * Time.deltaTime); }