Math question and assistance
by Sean T. Boyette · in Torque X 2D · 10/27/2008 (11:44 pm) · 3 replies
I am looking to instantly change the rotation of a character via the vector from the stick:
I need to convert this vector to a value on the pi of a cicle that it would represent. (I am sure I am saying this incorrectly)
for instance
(0,1) = straight up or .785
(1,0) = striaght to the right or 0 (or 3.14)
(0,-1) = straight down or 2.355
(-1,0) = Left - or 1.57
in order to multiply it by two and rotate the model via this:
any help would be appriciated.
Sean
Vector2 tmpVector= new Vector2(move.Sticks[0].X, move.Sticks[0].Y);
I need to convert this vector to a value on the pi of a cicle that it would represent. (I am sure I am saying this incorrectly)
for instance
(0,1) = straight up or .785
(1,0) = striaght to the right or 0 (or 3.14)
(0,-1) = straight down or 2.355
(-1,0) = Left - or 1.57
in order to multiply it by two and rotate the model via this:
SceneGroup.Rotation = Quaternion.CreateFromYawPitchRoll(0.0f, 0.0f, calculated value here);
any help would be appriciated.
Sean
About the author
#2
tdn.garagegames.com/wiki/TorqueX/PlatformerFrameworkShooter
10/28/2008 (12:46 pm)
Cool. There is also a TDN example from Henry Garle with an aiming function for the platformer framework that uses this rotation:tdn.garagegames.com/wiki/TorqueX/PlatformerFrameworkShooter
#3
Nice - this is really aimed at 3d objects, but Henry's aiming function is also good for an 2d implementation.
Sean
10/28/2008 (2:09 pm)
Zilla,Nice - this is really aimed at 3d objects, but Henry's aiming function is also good for an 2d implementation.
Sean
Torque Owner Sean T. Boyette
To rotate a character in the direction of the analog stick:
float radians; radians = (float)Math.Atan2(move.Sticks[0].Y, move.Sticks[0].X); SceneGroup.Rotation = Quaternion.CreateFromYawPitchRoll(0.0f, 0.0f, radians);