|Andreas Großschedl (Unknown)||01.11.2010 10:00|
I need to get the Rotation of steerables so i did that:
i need the ry value, but this is only 0 to 90 deg and 0 to -90 deg but i need 0 to 360 deg. Do i need a second value to compare?
|Markus Uphoff (Unknown)||01.11.2010 10:21|
|you want to know the rotation of the vehicle you drive at the moment?
local x,y,z = localDirectionToWorld(self.rootNode, 0, 0, 1);
local length = Utils.vector2Length(x,z);
local dX = x/length
local dZ = z/length
local TDirection = math.deg(math.atan2(dX,dZ))
if TDirection < 0 then
TDirection = 360 - (TDirection * -1)
TDirection is the direction in degree (0-360)
i hope i can help
|Andreas Großschedl (Unknown)||01.11.2010 20:37|
|yes, this works fine. Maybe you can tell me what you are doing here?
|Markus Uphoff (Unknown)||02.11.2010 17:35|
|what i´m doing here?
help other users and get help
|Andreas Großschedl (Unknown)||03.11.2010 07:07|
|Yes, of course! But that's not what i meant. I wanted to know what the base of this calculation is, because i maybe need such a thing a few times?
|Stefan Geiger - GIANTS Software||15.11.2010 09:25|
|The code calculates the angle of the object's z-axis about the world y-axis.
You should make yourself familiar with the atan2 function, this is the main part in the code above.
localDirectionToWorld(self.rootNode, 0, 0, 1) simply returns the vector of the object's z-axis.
|Andreas Großschedl (Unknown)||15.11.2010 14:39|
|Thank you for the explanation!
Note: Log in to post. Create a new account here.