using UnityEngine; public class TabletController : MonoBehaviour { [SerializeField] Animator TabletAnimator; private bool isShowing = false; private bool isMoving = false; void Update() { // calculate if player is moving if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D)) { isMoving = true; } else if (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.D)) { isMoving = false; } if (Input.GetKeyDown(KeyCode.T) && !isMoving) { // if is not showing play tablet open animation if (!isShowing) { TabletAnimator.Play("Tablet_Open"); } // if is showing play tablet close animation else { TabletAnimator.Play("Tablet_Close"); } isShowing = !isShowing; // Toggle state } } }