Game Development Community

T2dAngleBetween() wierdness? version 1.1 release

by Steve George · in Torque Game Builder · 06/23/2006 (9:55 pm) · 3 replies

This use to work for me...

%this.setImpulseForcePolar(t2dAngleBetween(%this.getPosition(),$player.getPosition()),20);

this should cause an object to launch itself towards another object...

As of the official release, its not working for me. Could there be something wrong with t2dAngleBetween or was I getting away with something that wasn't suppose to function in this manner?

~SG

#1
06/24/2006 (12:30 am)
Why not break that down into individual %vars and use echo() to see what's not working:

%thisPos = %this.getPosition();
%playerPos = $player.getPosition();

%angle = t2dAngleBetween(%thisPos, %playerPos);

%this.setImpulseForcePolar(%angle, 20);

echo ("this pos: " @ %thisPos);
echo("player pos: " @ %playerPos);
echo("angle: " @ %angle);
#2
06/24/2006 (6:43 am)
It's not weirdness so much as rewriting it to match the documentation. See this thread toward the bottom:
www.garagegames.com/mg/forums/result.thread.php?qt=44951

What you need instead of t2dangleBetween (which gives the angle between two vectors) is this:
%difference = t2dVectorSub( %playerPos, %thisPos );
%x = getWord(%difference, 0);
%y = getWord(%difference, 1);
%angle = mRadToDeg( mAtan(%x, %y) );
#3
06/24/2006 (10:48 am)
Thanks, J. Alan for pointing that out. All fixed now. I had that function throughout my entire project and nothing was working :)