Fix for Euler rotation broken (DEF-1636) (SOLVED)


Hey guys,

I’m struggling with the long standing bugs with Euler rotation not animating properly beyond the +/- 90 degrees mark.

Do you have a snippet of code to fix that in script? I can’t wrap my head around it…

Thanks in advance


How do you mean? What does your script look like?


I’m thinking about a simple script:

function M.update(self, dt)
go.set(".", "euler.z", go.get(".", "euler.z")+1)

The object will turn from 0 to 90 and then stay blocked.

Thanks in advance!


Wow, that’s pretty darn broken. I messed around with this for a bit and read the original bug-report threads. I think the only “solution” right now is to set the quaternion rotation every frame yourself. For example this works:

local z = 0

function update(self, dt)
	z = z + dt * 3
	go.set(".", "rotation", vmath.quat_rotation_z(z))

I couldn’t get anything useful working with go.animate(). I gather from Ragnar’s post that it doesn’t interpolate quaternions properly?

Interestingly, if you set euler.z on init() it will be correct, even with greater than 360-degree positive or negative values. But if you do the same exact thing at runtime with a value that’s on the “wrong” side of the circle, it will alternate sides each time you set it.


Solved in Defold 1.2.123