Get the angle of rotation?

Arghhh, I can’t find anything in the API documentation, I am either blind or to exited :wink:

Problem: I am having a object that is rotating. I do need to read the angle of the object, is it possible?

E.g: local Angle = myObject.angle

Joakim [import]uid: 81188 topic_id: 19247 reply_id: 319247[/import]

myObject.rotation [import]uid: 58777 topic_id: 19247 reply_id: 74253[/import]

I tested that but it only accumulates the value…so I can end up with a value of a couple of thousand…or should I divide it by 360 to get the accurate angle?

Joakim [import]uid: 81188 topic_id: 19247 reply_id: 74254[/import]

you can set up a function that will restore rotation to 0 if 360 was achieved… [import]uid: 16142 topic_id: 19247 reply_id: 74256[/import]

Yes, but the question is - how do I calculate that when the function is acumulating the value?

Joakim [import]uid: 81188 topic_id: 19247 reply_id: 74257[/import]

like that, i did something like that long time ago)
[lua]local function rotate()

obj.rotation = obj.rotation + 10

if obj.rotation >= 360 then
obj.rotation = 0
end

print("this object rotation is: "… obj.rotation)

end

Runtime:addEventListener(“enterFrame”, rotate)[/lua]

something like that, its right out of mind, so i didnt test it, try it ) [import]uid: 16142 topic_id: 19247 reply_id: 74259[/import]

BrightWaveGames

what does % symbol do? [import]uid: 16142 topic_id: 19247 reply_id: 74265[/import]

or you can just do
object.rotation = object.rotation %360
after you add or subtract from the rotation

[lua]function Loop()
object.rotation = object.rotation +1
object.rotation = object.rotation %360
print(object.rotation)
end

Runtime:addEventListener( “enterFrame”, Loop )[/lua]
[import]uid: 58777 topic_id: 19247 reply_id: 74264[/import]

% = modulus. in this case it limits the range of the rotation to values from 1-360 [import]uid: 58777 topic_id: 19247 reply_id: 74268[/import]

wow, great to know, definitely useful little symbol) [import]uid: 16142 topic_id: 19247 reply_id: 74270[/import]

Woww, thats so great…I have to look in the API documentation about this. Works perfect, just tried it. Big thanks!

Joakim [import]uid: 81188 topic_id: 19247 reply_id: 74271[/import]