• News

• Industries

• Learning & Support

• Community

• Marketplace

# Basic questions about rotation (from a newbie)

Hi everyone,

I’ve been experiencing with rotation in blueprint a lot lately, but can’t seem to get the basics straight and I’m finding different, contradictory explainations on the internet, so I’m just gonna ask a few things here:

1. When do I use which rotation (setworldrotation, setrelativelocation, addlocalrotation)?

2. Which boundaries do pitch, yaw and roll have? I found some info saying, that they must be between 0 and 360° which kind of makes sense to me, but If I print the rotations to the screen while my programm runs, the rotation values are often negative. So whats up with that?

3. Imagine I have a blueprint scene “root” and in a relative distance (e.g. 10,0,0) I have a static mesh body (e.g. a cube). If I rotate the root, the static mesh follows accordingly and it rotates around the same axis, which are the axis of the root, right? Shouldn’t be the pitch, yaw and roll compnents of the root and the static mesh be the same than? Because if I try this, I get different rotation values for the scene root and the static mesh body.

4. If I combine two rotators with the combine module (e.g. both have the values 5,5,5), why isn’t the result the sum (5+5 = 10) but some diffrent value?

I know these questions might be easy peasy for most of you, but I kind of got lost and I can’t seem to find out those basics. So thanks for every help in advance!

No one answered your previous 5 questions. LOL Ok, I’ll bite. But since you’ve been around since 2018, you must have seen the forums become a wasteland. If you don’t answer other people’s questions then this whole thing doesn’t work. You may feel you don’t know enough, but you’ve got access to some interesting tech, so you can probably help somebody. EDIT: I’ll wait to see what Nacho replies. But here’s some advice from someone who also finds rotations a total mindf**k (along with multiplayer). Note there are other gotchas than just -+ 180 vs 0-360. You may find yourself running into gimbal lock (or sudden axis-flip) after doing rotation ops, that will make your head spin even more. So overall, I recommend cheating wherever possible. Suggestions:

1. FindLookAtRotation is your friend here, as its probably the single most helpful node there is. You can pass it two vectors or points and it will do all the hard work for you.

2. Don’t ever use the SetRotation series of nodes if you can actually get away with using the AddRotation nodes. As AddRotation lets you manipulate rotations without having to deal with absolutes (you only need to deal with differences - so its much easier).

3. The other trick which you don’t see mentioned a lot, but is actually really helpful, is to spawn meshes into the world and control their x,y,z using keyboard keys x,y,z until you get the target alignment you need. Then use PrintString / Widget to display x,y,z to see what starting / ending points you need. This takes a lot of the mystery away.

As regards why the root versus sub-component have different rotations and why they aren’t the same. The root has world rotation, whereas the sub-component has rotation relative to the root (although you can change this in the editor location box options iirc). So they will only ever match if you use GetActorRotation on the root, and GetWorldRotation on the sub-component and the sub-component actually has a 0,0,0 x,y,z rotation.

2 Likes

Rotators are certainly one of the more confusing things in Unreal Engine. In the real world they are called Eulers (pronounced “Oiler”).

One thing that you must understand is the difference between World space and Local (aka Relative) space. World space is the space that something is in in your world when it has no parental transformation. In world space, +Z is up, -Z is down, etc. Now, local space is the space of something relative to transformations higher up in the hierarchy. In question 3, the “root” is in world space. The cube is subjected to the transformation of the root. Now, the pitch, yaw, and roll components weren’t the same for you. That’s because the root was in world space, while the cube’s rotation was displayed in relative space. The cube is getting the transform of the root by default, and then contributing its own transform on top of that. You can actually change the displayed type of rotation in the Details panel:

So, if your cube’s relative rotation is (0, 0, 0), then it will have the same rotation as the root. And, if you change the type in the Details panel to “World”, then it will be the same as the root.

1. It depends on the situation. SetWorldRotation sets the rotation of the component in world space, overriding the current rotation or parent’s rotation. So, if you rotate your “root”, and then call SetWorldRotation with (0, 0, 0) on the cube, then your cube will look completely unrotated. SetRelativeRotation sets the rotation of the component in relative space, relative to the parent. So, if you rotate your “root”, then rotate the cube, then call SetRelativeRotation with (0, 0, 0) on the cube, the cube will have the same rotation as the root.

2. The boundaries don’t really exist. Technically it’s from 0° to 360°, but you can go below 0° and above 360°. If you go below 0, then the degrees will be 360°+x. So, -90° is 270°, and -180° is 180°. If you go above 360°, then the degrees will be x-360°. So, 450° is 90°, and 540° is 180. If you go even further above, like 1080°, then you repeat the process. 1080° is 0°. Oh, and keep in mind, 0° and 360° are the same thing. All of this is how it will visually appear, but if you are doing animation, they do have special meanings, because 1080° would mean “flip 3 times”. Even though -90° is 270°, in animation, -90° would go a short bit backwards, and 270° would go a bit longer forwards.

3. I explained this in the beginning.

4. This is one of the great evils of Rotators… there are equivalent rotations! For instance, (-90, 0, -90) is the same thing as (90, 180, 90).

Wow! It feels like I just wrote an article on rotation! I hope it’s not too confusing, and I hope it helps!

2 Likes
1. I hate to tell you, but you use the one you need. You’ll discover that you need a different node, depending on what you’re doing. One thing I will say is, to avoid problems with the engine change 180 to -180, you might use AddLocalRotation to avoid that.

2. Again, the boundaries are -180 to 180 or 0 to 360 depending on how you inspect it. You CAN set to yaw to 30000, for instance, if you want to, but you’ll just get a value back in range. If you really can’t stand not knowing what rotation an object has, then you need to start using quarternions instead.

3. Combining rotations can be very counterintuitive. They should add up, IF, the object’s location is the same.

2 Likes

P.S. I’ve started three month ago, not in 2018

1 Like

Hi NachoMonkey2,

wow, I couldn’t have hoped for a more thorough explaination, so thank you so much! This was really helpful! Of course I have some follow-up questions

1. If I set the relative rotation of the cube to 0,0,0 and change the world rotation of it’s root to, let’s say 50,50,50, the relative rotation of the cube remains 0,0,0 and it’s world rotation is equal to the roots (50,50,50), is that correct? Is it somehow possible that the relative rotation of the cube changes (unwantedly) during the run of the programm without me redefining it?

2. So it doesn’t really matter if I dont use “clamp axis”, Unreal calculates the values on it’s own?

Have you had any experience with a sudden flip of the rotation somewhere around 0° or 180°? I sometimes experience a change in sign (from 180° to -180°). This appears if i work with unreal leap, so maybe that question is to offbeat

Hi ClockworkOcean,

this cleared up a lot aswell, especially the first and the last point, thanks for your help! I tried using quaternions in the past but I didn’t get very far because I don’t know how to define them (4 values? whats w?) and I couldn’t figure out how to combine them with Euler-Roation-values (Is it even possible?)

You’ll get on fine if you stick with Euler and only use AddLocalRotation when you have problems with it jumping between 180 and -180.

1 Like
1. Yes, the relative rotation would be (0, 0, 0) in that case. No, the relative rotation of the cube won’t happen on its own.

2. You don’t need to use “clamp axis”.

Quaternions are pretty complicated. I think they a defined in an axis-angle format.