Rotation around shifted pivot point

Hi…

if you imagine our Earth, lets say it has static rotation pitch = 20 (around Y), and then we want rotate it around Z axis (Yaw) dynamically = 0 - 360 deg.

However if you try this eg in Editor, you will see, that the rotation around Z axis does not coresspond to static Y 20deg rotation, because it rotates around Z but exactly from top of object, if you get me.

I want rotate it around Z axis, but with respect to Y axis static rotation = need to move pivot point of Z rotation…

Image will say it all haha

19291-earth.jpg

Thx

Hello lukas84,

It happens because you are using Euler angles (rotator). And it has fixed applying order (X => Y => Z).
To avoid this situation you UE4 provide a lot of ways to avoid this. It is couple of them:

  1. Like an option, you can rotate it around Y axis (20 deg., pitch, like in your example). Now if you try it rotate axis you will be rotate in global coordinate system. To switch to local coordinate system press combination Ctrl+`(additionally in right top of viewport you can find button that corresponds for that)
  2. Second way through the code. I recommended to you use quaternion’s. To init them you need to know axis of rotation and angle on which you want to rotate. For you example you need to two quaternion’s, first rotating around z-axis and second (it’s Earth axis наклон, you need rotate around some axis you want in plane XY). Then you need to take resulting quaternion by multiplication two above (be aware, the order quaternion applying is another then order in matrix multiplication, Qresult = Qxy * Qz). Than just convert resulting quaternion to Rotator and set it to actor.

Best regards,