• News

• Industries

• Learning & Support

• Community

• Marketplace

# Creating a runtime rotation Gizmo

Hey everyone,

I’ve been implementing a blueprint transform gizmo to translate and rotate actors at runtime in my build game. I have the translation working correctly, but I’'m struggling with the rotation aspect. There’s not a huge amount of info I could find online about how to do this. I’ll post a couple of links to what I have found. From what I understand, the best way to do this is using quaternions, but my understanding of them is lacking a bit.

The method described in this first link (Implementing simple translation and rotation gizmos // My thought repository) doesn’t use quaternions, but seems to just basically be a LookAt function between the actor and the ray-plane intersection. So the mouse must orbit the object to rotate it.

his second explanation seems to be more what I’m after, but I’m struggling to grasp this and translate it to blueprint (3d - How to translate mouse movement to a rotation gizmo? - Computer Graphics Stack Exchange).

I have the Blueprint quaternion library plugin, so have access to a lot of quaternion functions if need be. Currently I’m creating a plane with a normal equal to the axis of rotation, and doing a line-plane intersection from the mouse position to find an intersection point on that plane. I just don’t know how to translate the mouse movement to a rotation.

Any help is much appreciated!

What exactly do you want to do? Rotate an object to match another’s position? Ie. make it face another object?

So. The way I did this recently is for a real time strategy camera, but the concept is nearly identical on objects.

Create the mouse axis input and use it to determine if the mouse is moving and which direction it is headed on (based on axis).

You can then create a positional vector and turn it along to the object you need to rotate.
or you can just change the object’s local rotation by adding 1 every time the event is called.

You do need to isolate the initial node to keep it from constantly running.
just do if axis!=0 > true > your local rotation logic.

Rotating all 3 axis with only 2 movement axis won’t exactly be possible.
I would actually make an axis informed decision when dealing with x or y.
If camera and object have the same X I would affect the Y - and viceversa…
Z, the yaw, should probably always rotate with left to right…

Hi,
I found a very nice plugin for this, which I then modified to make it more compact and usable in a third person game. You can find the video here: https://youtube.com/watch?v=ZhBzu2JUbVM

Also the original plugin is here: https://github.com/xyahh/UE4RuntimeTransformer