Input System

The input system of the 2D platformer-sidescroller controller asset is based on Unity's new input system. It uses an InputActions.inputactions asset to define a set of input actions and an action map named "Player". The action map contains various actions such as Walk, Jump, Dash, Crouch, WallGrab, and WallClimb. The PlayerInputManager script utilizes the input actions and action map to manage and process user inputs from different devices like keyboards and gamepads

PlayerInputManager Script

The PlayerInputManager script is responsible for detecting and processing player input. It initializes an InputActions object to use the input map from the new input system, and it stores input values in private variables. The script also provides public properties to access these input values.

Initialization and References

In the Awake method, the script initializes the InputActions object, and sets up references to the PlayerMain and PlayerData components.

Input Event Functions

The OnEnable method is used to enable the input system and assign events to actions for detecting and processing input from the player. The input event functions include:

  • OnJumpStarted and OnJumpCanceled: Triggered when the jump input starts and is canceled, respectively.

  • OnWalk: Triggered when the walk input is performed or canceled.

  • OnDash: Triggered when the dash input is performed or canceled.

  • OnCrouch: Triggered when the crouch input is performed or canceled.

  • OnWallGrab: Triggered when the wall grab input is performed or canceled.

  • OnWallClimb: Triggered when the wall climb input is performed or canceled.

FixedUpdate and UpdateTimers

The FixedUpdate method calls the UpdateTimers method, which updates the timers related to coyote time, jump buffer, and dash cooldown.

Last updated