Hardcoding New Values for Axis Handling ( Input.get_axis() )

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By fattusrattus

So I’ve looked everywhere for a solution to this but I can’t find anything :confused:

I’ve been playing about with the Axis Handling system because it makes input actions so much cleaner and easier to manage, but the thing I want to know is how to remap the axis values? If that’s possible?

Looking to increase/decrease the actual mapping values instead of just -1 to 1, as I need it for a certain mechanic.

Thanks if you read this, and if you can offer some insight, please let me know!

:bust_in_silhouette: Reply From: SQBX

If you want the values to be “mirrored” (i.e. 5 and -5, 10 and -10, 2.5 and -2.5), you can do

var a = get_axis(negative_action, positive_action) * 5 # Change the 5 to whatever you want the actual value to be

If you want them to have a min and a max that are not mirrored, you can do

var a = get_axis(negative_action, positive_action) * (5 if get_axis(negative_action, positive_action) > 0 else 10)

This will make it so that the get_axis function will scale its value so that its minimum is -10 and its maximum is 5; Obviously change these values to whatever you need for your game

Finally implemented it to my liking and it works a charm!
Thank you so much :slight_smile: I was tryna rework a unity implementation and this is the gdscript equivalent of what I needed to do

fattusrattus | 2023-01-05 07:06