How to rotate an object in a specific direction?

Let’s say I have a cube at rotation 0,0,0 and then let’s say I rotate that cube forward in the X direction. Afterwards, the cube will be at rotation 90,0,0. If I try to rotate a cube forward in the Y direction first, its rotation then becomes 0,90,0 so if I then try to rotate it forward in the X direction, the new rotation will be 90,0,90.

The problem is that if I try to rotate this cube in a blueprint then I couldn’t use rotators to make sure it always rotates in the same direction regardless of its starting rotation. I’ve also tried using “rotation from axis and angle” and that didn’t work either. Does anyone know how I can rotate an object in the same direction regardless of its starting rotation?

You need to store the current and target rotations in variables. Don’t read from the object you’re rotating. Then you can just add any rotation you want:

This assumes you start at 0,0,0, but then you can go anywhere.

If you want to start from an unknown, then you need to use AddLocalRotation.

1 Like