Game Development Community

T2dGunTurret turning into wrong direction

by Shaderman · in Torque Game Builder · 08/22/2008 (5:24 am) · 2 replies

Hi,

I've made some test with t2dGunTurret but it doesn't face the target object correctly:

youtube video

Unfortunately, I don't have the TGB source (yet) and there are no docs about this class. Any ideas how to solve this?

#1
09/03/2008 (6:59 am)
Maybe you didnt take into account that the coordinate system in TGB its not like you're accustomed to in your regular math class.

well... a simple solution to your case (for what i could see in your video) is to add (or substract) 180 degrees to the angle your calculating for the turret to face the enemy (player), and you're set.

edit: somethin like this is what you need...
%vector = t2dVectorScale(t2dVectorNormalise(t2dVectorSub(%turret, %enemy)), -30);
%angle = 180-mRadtoDeg(maTan(getWord(%vector,0),getWord(%vector,1)));

there are some values that you dont really need, but i think you get the idea (thats a lil snippet i used to code a function for a homming missile).

with that "%angle" your turret should face the enemy correctly.
#2
09/04/2008 (9:25 am)
Thanks for your answer Ehrlichmann.

I just tried to use the t2dGunTurret class like Melv did in his post and didn't calculate anything myself. I assume it's a bug and thus I'll use something like your code and do the calculation on my own. It's not a big deal, I've just been curious and thought there might be an easy solution or some infos about this class or active tiles in general.

Thanks.

Stefan