hello everyone I’m using a PS4 controller in my project and i want to use one of the triggers value as an accelerator for the car in the project,
well I’m not that good with ps4 controller inputs so i used unity input manager to map my keys and when i set the Vertical axis to be my Right trigger it works but the values returned is -1 to 1.
i want to change this one to become 0 to 1
is that even possible ?
NB : never used the new input system, cause I’m already advancing in several projects and can’t go back to redo the whole project input mapping cause i have a deadline !
Multiply the axis value by half, then add another half onto it:
float axis = Input.GetAxis("some axis") * 0.5f + 0.5f;
1 * 0.5 + 0.5 = 1
-1 * 0.5 + 0.5 = 0
1 Like
In general, to remap any value from any given range to the [0, 1] range you can use Unity’s InverseLerp function:
For example:
float axis = Mathf.InverseLerp(-1f, 1f, Input.GetAxis("some axis"));