Some checks failed
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (push) Has been cancelled
Build project / Publish to itch.io (StandaloneLinux64) (push) Has been cancelled
Build project / Publish to itch.io (StandaloneWindows64) (push) Has been cancelled
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (push) Has been cancelled
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
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
|
|
|
|
|
|
}
|
|
}
|
|
}
|