How to get mesh local rotation?

I have a airplane mesh in a blueprint. It’s suppose to have a somewhat cartoonish behaviour, so I would like the plane to tilt slightly upwards when I brake. Kind of like what birds do when they “brake” in air before landing.

There’s the GetActorRotation and AddActorLocalRotation. I can make the actor tilt (pitch), and by reading the actor rotation I can also rotate it back until the actor pitch reads zero again. The problem with that is that the plane actor also will travel in the pitch directon. Meaning if I tilt it upwards when I brake, the plane will also begin to go upwards in direction. Instead of staying in it’s current direction while tilting it’s body.

I do want the plane to go in it’s pitch and yaw direction. That’s how I control the movement obviously. So what I really would want to do is to rotate the mesh during brakes, not the actor.

So there’s the AddLocalRotation function for the mesh. But I then want to rotate it back to zero once the actor speed has come to a full stop (or if I begin to accelerate again). Since I have a bunch of Lerps and functions to calculate a smooth tilt angle for the brake tilt, I really have no means of knowing the mesh’s actual rotation. I mean, I’ve been adding small values over time to the local rotation. And it appears as if there’s no “GetMeshRotation” to read the actual rotation.

Basically, how do I set the rotation on a mesh to zero when I don’t know the current rotation?

If you make the mesh local rotation be Identity, then you can always set the plane back to level by setting the rotation to Identity.
(There are a few ways to create the Identity rotation – you may want to create it by setting heading/pitch/roll to 0, which lets you set pitch to whatever you want when braking the plane.)
In general, games work best when the assets are made to be “right” with zero additional transforms applied, and this is a typical case of where that’s true.
If you need to apply another rotation to the mesh to point it in the right direction, then you might want to have a transform node in the actor, and the mesh under the transform node, and make the transform node have the identity rotation by default.

I think I’m too stupid to understand half of what you just said. I’m thinking, if there are means of setting the rotation to an absolute value (in this case the “Identity” you’re speaking of), shouldn’t it be possible to straight up set the rotation to zero instead? The only functions I cand find to rotate a mesh are the AddLocalRotation and AddRelativeRotation. Neither can set the rotation to an absolute value.

Like, I should really just not do the braking tilt rotation?

I don’t understand any of that. Is there any tutorials on the Identity concept you’re talking about?

First: The “identity” rotation is just the “0 / 0 / 0” rotation – also known as “no rotation.” It’s called the “Identity” because, in 3d Math, when you put in something to this rotation, you get the same thing out, unchanged, identical.

Second: You should absolutely have your plane do the tilt! What I was worrying about was whether you had rotated the mesh compared to the actor already – does your mesh component have a rotation when it’s in default mode?
In general, your mesh (airplane) should be built such that “forward” in the mesh is “forward” in the actor, and thus you can set the (local) rotation of the mesh component to 0 / 0 / 0 in your blueprint.

If we assume that that’s the case, then “undoing the braking tilt” is as easy as setting the local rotation value of the mesh component to 0 / 0 / 0!

However, if your mesh component needs some rotation to “line up” with the actor, then you need to remember that value, and set it back when the braking stops, instead of the more-easy-to-remember 0 / 0 / 0 value.

Are you sure? There should be “SetRelativeRotation” as well.

That should do what you want, as long as your mesh isn’t the root component for the blueprint.
If it is, you’ll need to add a dummy “SceneComponent” above it, so it can rotate in relation to the blueprint actor.

Ah, then I understand what you mean! Thanks. I did in fact make sure I exported the model in the right orientation, I’ve run into rotation issues before when I imported assets in the wrong orientation and ended up with elaborate calculations to make it work in the end.

Ah, thank you dear sir!! I never bothered to figure out what the difference between “Set” and “Add” was. For all I knew, both had to do with relative rotation. Meaning, delta rotation and not absolute. The SetRelativeRotation fixed everything, thank you!