UE4 Rotate object always on certain axis

Hello,

I am trying to make a picked up object rotate on a certain axis no matter what its local rotation is.

For those who played it:
It should be like it is in Gone Home.

For those who didn’t:
I’m making a system where you can pick up an item and then rotate it. I can make the item rotate by moving the mouse, but I want it so that when the mouse is moved forward, the object always rotates around a temporary ‘global’ axis, instead of its current local axis.

I hope it is clear,
thanks

Hello Roeney, just for clarification, when you mention that it’s rotating around a “temporary global axis” do you mean like this:

69328-global+rotation.png

Or this?

69329-local+rotation.png

Edit: For extra clarification on the question itself, both of those select rotation widgets are rotations along the Z axis (the blue one.)

The first one looks like what I want.

Have you tried using the Set World Rotation node? If not, what type of set up are you using to do your rotation? Anything that mentions Local rotation is going to give you a result akin to my 2nd picture. I just created a small blueprint for that chair to rotate overtime using a timeline and the Set World Rotation node and it spins along the global Z axis like in the first picture.

I was setting the rotation as follows:

  • Get Actor Rotation
  • Break Rotator
  • Add the mouse Y to the Y and X to the Z of the rotation
  • Make Rotator
  • Get Root Component (of the selected actor)
  • Set World Rotation of the Root Component to the Make Rotation

I changed it to:

  • Make Rotator with X:0, Y:Mouse Y, Z:Mouse X
  • Get Actor Rotation
  • Combine Rotators
  • Set World Rotation of actor’s Root Component to the Combine Rotators

This fixed rotation being stuck at 0 degrees, and rotation works a lot better overall.
The problem now is that I need a custom ‘Y’ axis, to make the object rotate around an axis parallel to the player’s Right Vector.
Any idea how to do this?

I eventually fixed the problem by creating a component in the Character’s actor and attaching the picked up object to this component. Then I set this object’s relative rotation for the Mouse Y (Y axis), and the world rotation for the Mouse X (Z axis). Rotation works perfectly now :slight_smile:

I’m trying to achieve the same thing you did right now.
Could you provide a screenshot of your blueprint? I think I don’t fully understand how you did the rotation.

I’m setting the world rotation for the Z- axis with Mouse X, too. This works perfectly.
But I don’t get the Y-axis rotation to work.

This is what I did so far: Rotate attached object in front of first person character - Blueprint Visual Scripting - Unreal Engine Forums

edit: nevermind, I got it to work, the additional component in the charactor made it work. Thanks!

No worries, I’m glad my solution worked for you too! :slight_smile: