Getting actor's relative rotation

Hi,
I’m having some difficulties/inconsistencies getting the relative rotation of an actor, which is attached to another actor.

Following setup:

  • Parent actor (named “Module”) with a socket
  • Child actor (named “Dock”; it’s not a Child Actor Component!)

On BeginPlay the Module actor spawns and attaches a Dock actor to a socket inside the Module.

At some point in time the Dock actor needs to know its rotation relative to its parent actor, the Module. It’s doing it like this:

229570-actor-relative-rotation.png

In my understanding the acquired relative rotation of the Dock shouldn’t be changing when I rotate its parent Module in the world. And it works perfectly fine as long as I don’t touch the Y rotation value of the socket the Dock is attached to. If Y is not equal 0 and I rotate the Module while playing, the relative rotation of the Dock it’s printing on the screen is constantly changing. If Y is equal 0, the relative rotation stays the same, no matter what I do with the Module, which is the expected result. Changing X and Z values of the socket’s rotation has no issues.

Is it just a bug or am I doing it completely wrong? Is there an other way to get the rotation of an actor relative to another actor?

I found out that the unexpected behavior of the inverse transform is caused by the gimbal lock. I solved this issue in C++ using only quaternions.

Hi there, could you go over specifically what methods to use to solve the issue? I’m having some rotation related problems as well, and I think your solution may help.