Finish my animations

This commit is contained in:
BuyMyMojo 2023-02-26 02:09:56 +11:00
parent 7c0c6eda6a
commit 0859e4b36c
12 changed files with 156 additions and 23 deletions

View file

@ -7,6 +7,8 @@ public class Player : MonoBehaviour
[SerializeField] private float moveSpeed = 7f;
private bool isWalking;
private void Update()
{
Vector2 inputVector = new Vector2(0,0);
@ -33,9 +35,15 @@ public class Player : MonoBehaviour
Vector3 moveDir = new Vector3(inputVector.x, 0f, inputVector.y);
transform.position += moveDir * moveSpeed * Time.deltaTime;
float rotateSpeed = 10f;
isWalking = moveDir != Vector3.zero;
float rotateSpeed = 10f;
transform.forward = Vector3.Slerp(transform.forward, moveDir, Time.deltaTime * rotateSpeed);
}
public bool IsWalking()
{
return isWalking;
}
}