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.
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.
@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
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
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.
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.
@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.
@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
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
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.
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.