Game Development Community

Rotation issue

by Richard Marrevee · in Torque 3D Professional · 03/26/2010 (1:24 am) · 4 replies

I am trying to turn the player in the opposite direction when it enters a trigger. So I have made a script which get teh transformation of the player with getTransform and grab the rotation angle part. Then I add 180 to the rotation and call setTransform. I get unpredictioned results. Sometimes it works, and other times it does not rotate the full 180 degrees. It also seems that subtracting 180 from the rotation angle give better results, but still not that what I expect.

When I manually rotate the player I get some strange values:
When the z-axis is -1 then I can rotate left until 119.999... degrees. When it gets to 120 then the z-axis flips to 1 and the rotation angle to 240. This seems not logical.

Is this a bug or am I on the wrong path for turning the player 180 degrees around?

I am using the 1.1 beta.

Hope someone can help me.

Thanks in advance.

About the author

Started programming in 1984 on an Oric, when time progressed switched to MSX, Amiga and finally the Windows PC with T3D. Now developing an epic fantasy game: The Master's Eye. Creator of the DoorClass pack and VolumetricFog pack @ richardsgamestudio.com


#1
03/26/2010 (7:55 am)
If you want to turn the player only ,then your direction should be straight up "0 0 1" and only sum 180 degrees with the old angle value.
#2
03/26/2010 (9:14 am)
SetTransform() uses radians. Try adding 3.14159 to the rotation instead of 180.
#3
03/26/2010 (1:04 pm)
Thanks guys, adding the rotation in radians and everything is ok.
#4
05/04/2010 (8:18 am)
Since we are on the subject:
In the game editor you can set rotation of an object 0 0 1 180 then when you obj.getTransform() it returns radians. I use markers to spawn objects and I getTransform() on the marker then obj.setTransform(get) and nothing lines up so is the editor wrong is get and set only in radians? If so why isn't the editor in radians? Nice pile of confusion there....... One of the devs explain things for us?