Move object based on euler angle

hello, i cannot figure this problem, when im setting rotation of game object in euler angles and then printing out the value in debug console, value is not bigger than -90/90 degrees.

my problem is that i want to move object based on angle, my code is:

init:

go.set(".",“euler.z”,math.random(0,360))
print(go.get(".",“euler.z”))

update:
local x = go.get(".", “position.x”) + (math.cos(math.rad(go.get(".",“euler.z”))) * speed * dt)
local y = go.get(".", “position.y”) + (math.sin(math.rad(go.get(".",“euler.z”))) * speed * dt)
go.set(".",“position.x”,x)
go.set(".",“position.y”,y)

object is moving only on the right side of screen

1 Like

Whoa… very weird bug.
Actually I knew that I have been able to use it before…

SOoo… I tried setting it, got the same result as you. Also tried animate it with go.animate and got the same weird result.

THEN I removed and go.get function (to print) and suddenly it worked as it should. Something in the go.get() function screws up the euler it seems. Definitely a weird thing.
I call bug.

For the time, try not to use the go.get() with the euler and see if it helps :smiley:

2 Likes

thanks :slight_smile: it works when im storing the angle in other variable

1 Like