Need help converting analog stick's vector to usable velocity
by Ezra · in Torque X 2D · 07/05/2010 (1:48 pm) · 2 replies
I'm needing to use the vector length of the analog stick as a multiplier for velocity... but I am running into the issue where the diagonals create a faster speed than if the stick were strictly horizontal or vertical.
Basically I'm getting numbers above 1.0 in the diagonals, the max being 1.4142~
Do I need to do any square root stuff to get this working? I seem to remember doing that for 8-way movement.
The result I'm looking to get is a measurement from 0.0 to 1.0, for how far the analog stick is being pushed away from the center.
Basically I'm getting numbers above 1.0 in the diagonals, the max being 1.4142~
Do I need to do any square root stuff to get this working? I seem to remember doing that for 8-way movement.
The result I'm looking to get is a measurement from 0.0 to 1.0, for how far the analog stick is being pushed away from the center.
About the author
Recent Threads
#2
07/05/2010 (6:10 pm)
excellent, that is what I was looking for, thanks! I am just clamping it right now which seems to work, noticed I was getting 1.1's in some portions of the stick.
Torque Owner Duncan Colvin
You should also double check that the value you get is not greater than 1.0 - it's possible to move the stick outside of the normal circle if the user has a modded gamepad (or other special gamepad) or just through general wear and tear (see marble blast ultra on xbla for an example of people taking advantage of this 'feature').