Archived

This topic is now archived and is closed to further replies.

Fine Tuning Analog Controller Scheme

This topic is 5041 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

(I meant to post this here originally) My action mapper sends me my analog or joystick feedback on a scale -1 to 1 on both the RightLeft axis and UpDown axis. I managed to create a reasonably smooth camera-relative directional control out of it but I have one small problem left -- character velocity. If I use the magnitude of the original vector the character runs faster for diagonal directions on the analog or joystick. That's because going straight left(or right) gives me a magnitude of 1.0f(at full speed) and same for straight Up or Down on the analog - BUT at diagonals I have say 1.0f right AND 1.0f up ,which gives me root2 for magnitude which is bigger than 1.0f -- but it should only be 1.0f at any maximum direction. How do I get a magnitude for finding velocity out of the analog or joystick control??? Any ideas???? [edited by - pixelstar on February 21, 2004 12:45:52 AM]

Share this post


Link to post
Share on other sites
Calculate the angle of the direction the controler is pointing using arctan(UpDown / LeftRight) and say this angle is theta. Since x=cos(theta) and y=sin(theta) will give you a unit vector (x,y) you now only want a percentage of each of those values and since UpDown and LeftRight and values from 0 to 1 you just need to multiply by these two values ie x=abs(LeftRight) * cos(theta) and y=abs(UpDown) * sin(theta). Arctan gives results from -Pi/2 to Pi/2 so you will have to write in checks to get correct results.

[edited by - O_o on February 22, 2004 1:13:38 AM]

Share this post


Link to post
Share on other sites
After thinking unit vector I think x=LeftRight*abs(LeftRight)/sqrt((LeftRight^2+UpDown^2)) and y=UpDown*abs(UpDown)/sqrt((LeftRight^2+UpDown^2)) gives the same result and would be faster and no if statements needed, no trig functions and only one root.

[edited by - O_o on February 22, 2004 2:13:23 AM]

Share this post


Link to post
Share on other sites
Awesome! It''s working perfectly now!! :D
The control feels like Jak and Daxter now (my favortie PS2 game). Now I just have to smoothen out the animation blending and I''m on my way.
One question(subjective). Moreless asking for advice. I''m wondering if the directX action-mapper takes care of jopystick/analog DEADZONE good enough or if I should use my own DEADZONE and let the user modify the DEADZONE and sensitivity? Maybe it''s a waste of time? What would you do?

Share this post


Link to post
Share on other sites