Go.animate and continuous rotation [SOLVED]

Hi everyone,

not sure this is not a stupid question but my brain refuses to work properly today.
When trying to generate a continuous linear rotation animation on z-axis for a game object, I first used the common trick of incrementing rotation on z-axis for each update:

function update(self, dt)
    local angle = math.pi/120
    local current_rot= go.get_rotation()
    go.set_rotation(current_rot * vmath.quat_rotation_z(angle))
end

It works, but I find it ugly as hell, as it’s neither efficient nor flexible. I’d rather use an animation loop such as go.animate but, this latter doesn’t provide a real control over the interpolation probably ending in interpolating each term of starting quaternion to end values of given quaternion. Following code shows how an 180 deg. rotation done as such goes wrong:

local url = go.get_id()
local prop = hash("rotation") 
go.animate(url, prop, go.PLAYBACK_ONCE_FORWARD ,vmath.quat_rotation_z(math.pi), go.EASING_LINEAR, 8, 0)

Basically is there no other way than quaternion to animate the rotation of game objects through your helper function? Or am I missing something (which is certainly the case) ?

In any case, thanks for your help.

There is a property “euler” that you can animate:

go.set(".", "euler.z", 0)
go.animate(".", "euler.z", go.PLAYBACK_LOOP_FORWARD, 360, go.EASING_LINEAR, 2.0)
2 Likes

Excellent ! exactly what I was looking for.
Thank Sicher.

Just realised it was listed in the docs about game object properties that somehow I read 3 times without noticing it…