Dual stick shooter code
by John Bura · in Torque X 2D · 08/31/2010 (6:52 pm) · 5 replies
Hi Guys,
Im trying to write a dual stick shooter code but it doesn't seem to be working. Ive spent an embarrassing amount of time trying to get this done. :P This is just part 1 where I can get the controllers to work. The next step will be to fire when the stick is all the way to one side. I think that that part should be easy.
Has anybody got this to work :)
Im trying to write a dual stick shooter code but it doesn't seem to be working. Ive spent an embarrassing amount of time trying to get this done. :P This is just part 1 where I can get the controllers to work. The next step will be to fire when the stick is all the way to one side. I think that that part should be easy.
SceneObject.Rotation= (float)Math.Atan2((double)move.Sticks[1].Y, -(double)move.Sticks[1].X);
Vector2 direction = T2DVectorUtil.VectorFromAngle(SceneObject.Rotation);Has anybody got this to work :)
#2
I tried something like this but it says I can't covert vector 2 to movestick.
Does anybody know how to solve this :)
09/01/2010 (1:50 pm)
@ ChristopherI tried something like this but it says I can't covert vector 2 to movestick.
Vector2 direction = move.Sticks[1];
direction.Normalize();Does anybody know how to solve this :)
#3
09/01/2010 (3:28 pm)
If I'm understanding the question correctly, this should workif(move.Sticks[0].X != 0f || move.Sticks[0].Y != 0f)
_sceneObject.Rotation = T2DVectorUtil.AngleFromVector(new Vector2(move.Sticks[0].X, -move.Sticks[0].Y));
#4
09/01/2010 (3:40 pm)
Thanks that worked perfectly! All I have to do is implement the fire code and it should be done :).
#5
So you'd have to do:
09/01/2010 (10:20 pm)
I'm sorry, it was late, I made a mistake. You'll have to convert it to a Vector as the sticks are treated differently by torque.So you'd have to do:
Vector2 direction = new Vector2(move.Sticks[1].X, move.Sticks[1].Y); direction.Normalize();
Torque Owner Christopher Perkins
Finally, rotation is in degrees with torque, so you'll need to convert from radians to degrees in order to set your rotation right:
Should do it.