Class ThirdPersonInput
- Namespace
- WitShells.ThirdPersonControl
Handles player input using Unity's New Input System PlayerInput component. Requires PlayerInput component with "Move", "Look", "Jump", "Sprint", and "Crouch" actions.
public class ThirdPersonInput : MonoBehaviour
- Inheritance
-
ThirdPersonInput
Fields
OnCrouchInput
public UnityEvent<bool> OnCrouchInput
Field Value
- UnityEvent<bool>
OnJumpInput
public UnityEvent OnJumpInput
Field Value
- UnityEvent
OnLookInput
public UnityEvent<Vector2> OnLookInput
Field Value
- UnityEvent<Vector2>
OnMoveInput
public UnityEvent<Vector2> OnMoveInput
Field Value
- UnityEvent<Vector2>
OnSprintInput
public UnityEvent<bool> OnSprintInput
Field Value
- UnityEvent<bool>
Properties
CrouchInput
True while crouch is held.
public bool CrouchInput { get; }
Property Value
JumpInput
True when jump was pressed this frame.
public bool JumpInput { get; }
Property Value
LookInput
Current look/camera input vector.
public Vector2 LookInput { get; }
Property Value
- Vector2
MoveInput
Current movement input vector.
public Vector2 MoveInput { get; }
Property Value
- Vector2
SprintInput
True while sprint is held.
public bool SprintInput { get; }
Property Value
Methods
OnCrouch(InputValue)
Called by PlayerInput when Crouch action is performed.
public void OnCrouch(InputValue value)
Parameters
valueInputValue
OnJump(InputValue)
Called by PlayerInput when Jump action is performed.
public void OnJump(InputValue value)
Parameters
valueInputValue
OnSprint(InputValue)
Called by PlayerInput when Sprint action is performed.
public void OnSprint(InputValue value)
Parameters
valueInputValue
RegisterCameraController(CinemachineCamLookInput)
Register a CinemachineCamLookInput component to receive look input.
public void RegisterCameraController(CinemachineCamLookInput camera)
Parameters
cameraCinemachineCamLookInput
RegisterController(ThirdPersonControl)
Register a ThirdPersonControl component to receive input.
public void RegisterController(ThirdPersonControl controller)
Parameters
controllerThirdPersonControl
SetCursorLock(bool)
Locks or unlocks the cursor.
public void SetCursorLock(bool locked)
Parameters
lockedbool
ToggleCursorLock()
Toggle cursor lock state.
public void ToggleCursorLock()
UnregisterCameraController()
Unregister the current camera controller.
public void UnregisterCameraController()
UnregisterController()
Unregister the current ThirdPersonControl component.
public void UnregisterController()