Table of Contents

Class ThirdPersonInput

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

bool

JumpInput

True when jump was pressed this frame.

public bool JumpInput { get; }

Property Value

bool

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

bool

Methods

OnCrouch(InputValue)

Called by PlayerInput when Crouch action is performed.

public void OnCrouch(InputValue value)

Parameters

value InputValue

OnJump(InputValue)

Called by PlayerInput when Jump action is performed.

public void OnJump(InputValue value)

Parameters

value InputValue

OnSprint(InputValue)

Called by PlayerInput when Sprint action is performed.

public void OnSprint(InputValue value)

Parameters

value InputValue

RegisterCameraController(CinemachineCamLookInput)

Register a CinemachineCamLookInput component to receive look input.

public void RegisterCameraController(CinemachineCamLookInput camera)

Parameters

camera CinemachineCamLookInput

RegisterController(ThirdPersonControl)

Register a ThirdPersonControl component to receive input.

public void RegisterController(ThirdPersonControl controller)

Parameters

controller ThirdPersonControl

SetCursorLock(bool)

Locks or unlocks the cursor.

public void SetCursorLock(bool locked)

Parameters

locked bool

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()