Managing Inputs
Setting up Input System





Locate the PlayerControls asset within the UHFPS -> Scriptables -> Input folder. To open the Input Actions window, double-click on the asset.


To create a new input action, simply click on the (+) icon found to the right of the Actions tab name. Enter the name of the action in the localization key pattern.
Select the newly created action and modify the Action Type to the desired input type.

Next, click on the <No Binding> and choose the key you want your action to utilize.

If you are using a custom controls asset, ensure that you assign the reference to this asset within the Input Manager component.

In order to access input actions within a script, simply use the Input Manager functions. There are multiple ways to utilize the input.
using UnityEngine;
using UHFPS.Input;
private void Update()
{
if (InputManager.ReadButtonToggle(this, Controls.CROUCH))
{
// do something when toggled on
// even if you don't hold any button
}
if (InputManager.ReadButtonOnce(this, Controls.FIRE))
{
// do something once as button
}
if (InputManager.ReadButton(Controls.FIRE))
{
// do something every update as button
}
if(InputManager.ReadInput(Controls.LEAN, out float direction))
{
// do something every update with value
}
}

Last updated