diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-01-31 13:05:30 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-01-31 13:05:30 +0800 |
| commit | d08e5a8128025b19c34b07b5e754749a0c3b6844 (patch) | |
| tree | 0c63543674532440dc2ce5b317f8005b9aa6031b /Assets/Scripts/GrabStateMachine.cs | |
| parent | 64e326ff1720ceb5e4bdcb9a763f62de8ffbee4f (diff) | |
实现相机
Diffstat (limited to 'Assets/Scripts/GrabStateMachine.cs')
| -rw-r--r-- | Assets/Scripts/GrabStateMachine.cs | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/Assets/Scripts/GrabStateMachine.cs b/Assets/Scripts/GrabStateMachine.cs index 8242097..4695457 100644 --- a/Assets/Scripts/GrabStateMachine.cs +++ b/Assets/Scripts/GrabStateMachine.cs @@ -2,16 +2,9 @@ using UnityEngine; public class GrabStateMachine : MonoBehaviour { - private bool grabbing = false; - - // 动画组件引用(需要在Inspector面板赋值,或通过代码自动获取) - [Header("动画组件引用")] + public PlayerControl playerControl; [SerializeField] private Animator anim; - // 按键设置(可在Inspector面板修改,无需硬编码) - [Header("控制按键")] - [SerializeField] private KeyCode grabKey = KeyCode.G; - /// <summary> /// 初始化 /// </summary> @@ -22,26 +15,12 @@ public class GrabStateMachine : MonoBehaviour private void Update() { - DetectGrabKeyInput(); UpdateAnimatorState(); } - private void DetectGrabKeyInput() - { - if (Input.GetKey(grabKey)) - { - grabbing = true; - } - - if (Input.GetKeyUp(grabKey)) - { - grabbing = false; - } - } - private void UpdateAnimatorState() { - anim.SetBool("grabbing", grabbing); + anim.SetBool("grabbing", playerControl.grabbing); } } |
