Game Development Community

Cursor Return to Player?

by James Slade · in Torque X 2D · 05/30/2010 (5:03 am) · 1 replies



I have a sidekick (shane) controlled by the right analogue stick:


_Shane.Physics.VelocityX = move.Sticks[1].X * 55.0f;
_Shane.Physics.VelocityY = -move.Sticks[1].Y * 55.0f;

I want this character to move towards the main player when the right analogue stick isn't moving but want to be able to control it when the right stick is. A self-centreing sidekick so to speak.

I know the code to send him back to the main character (vic):


_Shane.Physics.Velocity = T2DVectorUtil.VelocityFromTarget(_Shane.Position,
_Vic.Position, 10);

but don't know how to check to see if the stick is being moved. Any help gratefully appreciated.

#1
05/30/2010 (5:55 am)
If the X or Y stick values are zero then the stick is not being used (it has been returned to the center position).