Q - How to setup gamepad axis threshold?

Hello, everyone! I hope you’re doing well.

I am a newbie getting game coding. I am doing changes to the “Walking astronaut tutorial” and recently configured the gamepad input, the issue is that the axis needs some sort of safe area or threshold because when the configured movement stick is moved down or up it will move to the right or the left as well (and viceversa), the object is supposed to behave like that only if I move the stick diagonally (unsure because I don’t know how to configure it).

In the meantime I removed the bindings for Y-axis, in the image below I illustrated the response area of the X-axis (blue shape). Where the circle represents the stick area and the red cross both axis.

image

I suggest that you store your analog stick values in one variable for horizontal and one for vertical input and ignore the smaller of the two values, and if they are roughly the same you treat them as a diagonal move.

2 Likes