From bdd0c3eee905c5dc6fcf22344f7fdbd4cc3e3a02 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 30 Jan 2026 23:07:07 +0800 Subject: 完成双角色操纵 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/GameControllerInput.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Assets/Scripts/GameControllerInput.cs (limited to 'Assets/Scripts/GameControllerInput.cs') 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(); + } + + public void OnMove(InputAction.CallbackContext context) + { + Vector2 input = context.ReadValue(); + _playerControl.movementHorizontal = input.x; + _playerControl.movementVertical = input.y; + } + + public void OnGrab(InputAction.CallbackContext context) + { + float value = context.ReadValue(); + bool isGrabbing = value > 0.5f; + _playerControl.grabbing = isGrabbing; + } +} -- cgit