using System.Collections; using System.Collections.Generic; using UnityEngine; using Autohand.Demo; using UnityEngine.InputSystem; namespace Autohand.Demo { [HelpURL("https://app.gitbook.com/s/5zKO0EvOjzUDeT2aiFk3/auto-hand/controller-input")] public class OpenXRHandPlayerControllerLink : MonoBehaviour{ public AutoHandPlayer player; [Header("Input")] public InputActionProperty moveAxis; public InputActionProperty turnAxis; private void OnEnable() { if (moveAxis.action != null) moveAxis.action.Enable(); if (moveAxis.action != null) moveAxis.action.performed += MoveAction; if (turnAxis.action != null) turnAxis.action.Enable(); if (turnAxis.action != null) turnAxis.action.performed += TurnAction; } private void OnDisable() { if (moveAxis.action != null) moveAxis.action.performed -= MoveAction; if (turnAxis.action != null) turnAxis.action.performed -= TurnAction; } private void FixedUpdate() { player.Move(moveAxis.action.ReadValue()); player.Turn(turnAxis.action.ReadValue().x); } private void Update(){ player.Move(moveAxis.action.ReadValue()); player.Turn(turnAxis.action.ReadValue().x); } void MoveAction(InputAction.CallbackContext a) { var axis = a.ReadValue(); player.Move(axis); } void TurnAction(InputAction.CallbackContext a) { var axis = a.ReadValue(); player.Turn(axis.x); } } }