summaryrefslogtreecommitdiff
path: root/Assets/Scripts/GameControllerInput.cs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-30 23:07:07 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-30 23:07:07 +0800
commitbdd0c3eee905c5dc6fcf22344f7fdbd4cc3e3a02 (patch)
tree2a8fb0c76b134890aa61dcc9e9949cedab055f57 /Assets/Scripts/GameControllerInput.cs
parentb0642164b112508bbfc0b60553586ea260a79d2e (diff)
完成双角色操纵
Diffstat (limited to 'Assets/Scripts/GameControllerInput.cs')
-rw-r--r--Assets/Scripts/GameControllerInput.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/Assets/Scripts/GameControllerInput.cs b/Assets/Scripts/GameControllerInput.cs
new file mode 100644
index 0000000..ff29c12
--- /dev/null
+++ b/Assets/Scripts/GameControllerInput.cs
@@ -0,0 +1,27 @@
+using UnityEngine;
+using UnityEngine.InputSystem;
+
+[RequireComponent(typeof(PlayerControl))]
+public class GameControllerInput : MonoBehaviour
+{
+ private PlayerControl _playerControl;
+
+ private void Awake()
+ {
+ _playerControl = GetComponent<PlayerControl>();
+ }
+
+ public void OnMove(InputAction.CallbackContext context)
+ {
+ Vector2 input = context.ReadValue<Vector2>();
+ _playerControl.movementHorizontal = input.x;
+ _playerControl.movementVertical = input.y;
+ }
+
+ public void OnGrab(InputAction.CallbackContext context)
+ {
+ float value = context.ReadValue<float>();
+ bool isGrabbing = value > 0.5f;
+ _playerControl.grabbing = isGrabbing;
+ }
+}