*VIDEO* Roll mesh component in the direction of angular velocity (relative roll)

I’m trying to get my little aircraft pawn’s mesh component to roll as it turns, a bit more like a real aircraft but also cartoon-like.

So I’ve been able to get the angular velocity, and even managed to get the FORWARD red arrow (relative rotation) to point to the angular velocity (which where I’d like the UP of the aircraft mesh (relative rotation) to roll to). Here’s a VIDEO.

Would someone please help? Thank you :slight_smile:

1 Like

Presuming “cartoon-like” means the plane is never upside down you’d need to FInterp towards the roll of the arrow, but clamp values between -89 and +89. Make sure you convert anything above +180 to -180 (e.g. +181 should be -179); that way you always get the shortest path from 0 (plane is horizontal).
The Lerp node for rotators has a “shortest path” bool iirc. That might help as well.

1 Like

@CrispClover Thank you for getting back to me on this. My challenge is that the arrow is just relative pitch and yaw (Rotation from XVector always has zero roll). So my issue is how to convert the arrow’s relative pitch and yaw, to give the plane mesh component relative roll.

Also, the FORWARD of the arrow (XVector) is the direction that would be the UP of the mesh.

Actually, I think it might be good if the aircraft inverted itself when pitching down. I’d like to experiment with both… but I’m having difficulty even with the basic scenario :wink:

1 Like

If your arrow has its +X pointing up, then, presuming the other axes are also aligned with the local coordinates, you can try plugging the yaw into the roll, if that doesn’t work try plugging the pitch into the roll. (You might have to rotate by 90 degrees somewhere before everything aligns perfectly so don’t get discouraged if the ship is on its side.)

@CrispClover Exactly, this is what I’ve been trying to figure out… but it needs a combination of Pitch and Yaw (tried adding and subtracting) plugged into Roll, or somehow rotate the rotator.

I’ve been futzing with combinations just like this for ages, but I’m hoping someone might know :slight_smile:

Hold on, I may have misunderstood this. Are you saying the mesh is flying towards its relative +Z? Can you give me a screenshot of the plane inside the BP Viewport?

@CrispClover Nice one… the plane mesh should roll (relative rotation) so it’s top faces the direction it’s turning (local angular velocity), so it’s UP vector points to the arrow. :slight_smile:

So if it’s:

  • flying up, it rolls level
  • flying down, it rolls to upside down
  • flying right, it rolls to the right
  • flying left, it rolls left

… and the rotations in between, like half down and half right, roll halfupside down.

As you’ll understand, the plane mesh shouldn’t point in the same direction as the arrow, which would be straightforward to do.

You could try this: (EDIT: I forgot to plug all the inverse transforms in, reuploaded a new screenshot.)

It will look very odd if the plane suddenly rolls upside down when you pitch down while being horizontal.

2 Likes

Assuming you want to roll when just turning left/right: Try setting roll to the world angular accel yaw component, multiplied by a scalar.

2 Likes

@CrispClover You did FANTASTIC… it’s pointing the forward vector instead of the up vector, but it’s ALMOST THERE! Check out the VIDEO

@Countsie Yes, I started out with this approach. This so much simpler and it does look quite good.

But by quickly rolling the plane in the direction of angular velocity, I suspect it would look more dynamic and (in a cartoon-like way) more realistic.

OH! I think I may have found the real culprit to all of our confusion. No rotation applied to the mesh here:

This should (hopefully) work:

2 Likes

@CrispClover Do U use patreon… I absolutely must buy U a ‘coffee’. I tried the relative rotation (with both + and - Angle Deg) and it’s not quite there VIDEO

I’ll experiment the world rotation version now… if it works, I can try driving the whole pawn by feeding in the roll into ‘Set Control Rotation’.

2 Likes

One issue that will likely cause some weird behaviour is an angular velocity of zero. You might have to check for that and perhaps slowly let the rotation return to its “resting state”.

@CrispClover mmm… for consistency with how pitch and yaw are set using control rotation inputs, I thought to keep mesh component relative rotation to zero, and instead set the pawn’s roll using your world angular rotation with Set Control Rotation, but it just goes absolutely wild VIDEO

1 Like

The angular velocity is calculated on the pawn’s capsule component, (probably) based on what happened in the previous frame (iirc). So setting the controller rotation roll like this (especially without any interpolation) will likely let the angular velocity spiral out of control, due to a circular dependency between controller and pawn rotations.

“circular dependancy” sounds right to me :slight_smile:

So I went back to the relative rotation of the mesh component instead… and tweaked your approach. As you can see on the VIDEO it works!

Here are the tweaks to the @CrispClover formula, which I tinkered with until it all lined up:

I’m glad we experimented 360 degree roll setup, but (as @CrispClover suggested) simplifying the setup so that it only rolls (+/- 90) with yaw seems to be visually better and a bit smoother… and definitely simpler to blueprint.

VIDEO

Also, with a similar approach, Set Control Rotation works too…

1 Like