Go.get_world_rotation() incorrect on scaled game objects (Issue-3463)


Hi! As the title says, if I try to use go.get_world_rotation() on an object with a scale factor different from 1, the value of the quaternion is incorrect.

Is this a bug or a limitation of having to decompose the final model matrix of the object? Is there any way to get the world rotation on a scaled object?

EDIT: To be more precise, I’m working in pure 2D with uniform scales and my goal is to get to sin(alpha) and cos(alpha) where alpha is the global rotation-around-Z angle of a sprite. I need this to do manual picking (because when working with game objects, you don’t have gui.pick_node()).

1 Like


Quaternions are not my forte but @Mathias_Westerdahl or @Andreas_Tadic should be able to give some insights.

1 Like


Why aren’t you using collision objects for picking instead of calculating it all yourself?

1 Like


Because the ray cast API is async, which means I can’t promptly and correctly return true from on_input



I am using get_world_position/rotation for picking, it works, but I don’t have nested objects.

1 Like


I just ran into this bug myself. It’s a deal-breaker for doing world-to-local transforms (and vice versa) with game objects.

Here’s a minimal example demonstrating it: Defold Get World Rotation Bug.zip (2.6 KB)
And even a gif!
The line is drawn with a vector rotated with the normalized result of go.get_world_rotation(), so you can see that you get a wildly different rotation depending on the scale of the object. (If you don’t normalize the quaternion the vector also gets scaled when you rotate it.)

(Note: the result is very similar if you use a uniform scale as well.)

1 Like

World to local transforms

I also ran into this bug about 2 weeks ago. It would be good to fix this in the engine.

1 Like


I would actually be happier if we could get the entire world transform matrix of an object. It’s much more useful if you want to transform between coordinate spaces.

1 Like

World to local transforms

I was just going to comment this myself. Definitely. A go.get_world_transform function would stop this from being a blocker.

1 Like


@sven and @jhonny.goransson we should spend an hour investigating this issue on Monday.



Would be nice to be able to use go.get(component, 'mtx_view') to retrieve needed matrices.
At the moment this thing return a zero vector(4) for some reason. And trying to specify game object instead of a component results in a crash, heh.

1 Like


Think I have a fix for the get_world_rotation function at least:

We also have a task in our current sprint to add a function for getting world transform aswell, but no work has been done towards that yet.