Setting Flying Pawn Roll when Turning

Hello,

I’m trying to setup a flying pawn that will roll about 5-10 degrees left or right depending on input. The flying pawn has control forward, backward, left, and right and also has left/right steering through yaw manipulation. I intentionally do not want pitch/altitude control, as I want to keep that constant. Any tips on how to get the pawn to roll slightly without completely jacking up the movement?

Thanks!

I imagine that when you tried to introduce the roll into your Left/Right Steering block at the bottom there that you inadvertently introduced those pitch issues that you said you don’t want - correct? This problem occurs when you get a Right Vector in the 2nd image because when rolled 5-10 degrees this vector is no longer level with the horizon. There are a couple ways to counteract that…

First I would store the Axis Value from your turnAxis input at the bottom there into a custom variable. I’d recommend that you make two actually because in order to get the plane to blend nicely and not pop back and forth you’ll eventually want to RInterp the roll from its actual angle (Current) towards this input axis value (Target) with some set interp speed / delta time.

Next, you could use this value to counter rotate the Get Actor Rotation output in order to find a proper Right Vector … although this will get pretty messy and your head will explode trying to work out the rotations. So honestly what I would do is actually roll just the Static Mesh Component piece that ‘is’ visible and not the entire pawn system. That way when the blueprint tries to figure out which way is to the “right”, you’re still in the coordinate system you wanted despite the fact it looks like the plane has visibly rolled to either side a bit.

To do this, drag the static mesh from the components list (note - this could also be a skeletal mesh component) into your blueprint. Pull a pin from its blue circle and type “Add Local Rotation”. Note: The target text in italics along the header should say “Target is Scene Component” and not “Target is Actor” like it does on yours. Do some math on the Axis Value to cut down how much roll it gives you and feed it into the Delta Rotation on this node… although like I mentioned, you’re going to eventually want to incorporate an RInterp somewhere in that chain to make it fly nicely and also probably Clamp it to some min/max extreme in case you later change your input settings.

Thanks very much for the suggestions! I’m still very much a newb with blueprints, and am coming from scripting in code, as opposed to the visual style of blueprints, which makes learning them, for me at least, somewhat challenging.

I’m at a point now where roll is being accurately calculated based on the axis input (currently -5/5 depending on input). However, when I play, the actual mesh doesn’t roll. It’s also worth point out that I’m currently just testing this on a simple quad pyramid, as I’m still waiting for my artist to deliver the spaceship assets…not sure if that would make a difference.

I’m also not sure if I hooked up the lerp for the rotation correctly, as my roll values aren’t actually approaching the target, merely a fraction thereof.

Again, thanks for the help!

No problem - you’re almost there. The reason its not rolling very far is that you’re always trying to interp from a current roll of 0 degrees +/- a tiny amount you get each frame from the input. That’s basically completely ignoring any roll just did a split second ago and continuously keep leveling your ship out.

Here’s how to fix: From the ship mesh, drag a pin and get that mesh’s Local Rotation … feed that result into the “Current” pin on the RInterp. That way if you are banked by 5 degrees, your input will add a little on or take a little off of the 5 degrees instead of starting from zero.

Also - Instead of using the Event Tick to feed the Delta Time on that same RInterp block - right click and find the Get World Delta Seconds function. Does the exact same thing but wont clutter multiple functions in this one part of your blueprint, and you can then use the Tick event for other stuff elsewhere.

When I drag a pin from the ship mesh I have the option to call getWorldRotation() getSocketRotation() or to get transform variables with get absolute rotation and get relative rotation…nothing discretely getting the local rotation of that mesh. I did some trial and error with the results of those function/node calls and when I steered left or right the pawn just started spinning uncontrollably. Thanks for the tip about getWorldDeltaSeconds(), that worked out very well!

OK - instead of trying to tackle two new things at once, I’d say toss out the RInterp stuff for the moment and get the banking working correctly. Use the Get World Rotation of the mesh - break it apart using a Break Rot function - and just mess with your math on the the Roll part of it until it does exactly what you want without going out of control.

Then you can decide later if the movement is fine, or stutters too much for your liking and try to go back to using an RInterp to make it glide smoothly. One thing I try to get better as is more frequent testing (which is harder than it sounds) cuz I’ll easily construct page after page of blueprint and when it doesn’t do what I thought I waste more time trying to fix it than test along the way. LOL

After more tinkering what I found was that because I locked the Z axis rotation of the ship (to stabilize movement) that nothing was going to work with regard to z axis rotation…derp. When I unlocked it though, what ended up happening was the ship mesh would rotate in world space and movement would get all jacked up. I added some accessory meshes on the side of my ship pyramid and was able to manipulate them just as I would want the regular ship to be. What I’m thinking now may be the best bet is to have the artist build some animation into the final ship to handle these rotations, which hopefully will add the aesthetic I’m looking for while preserving the control I need. Thanks again for all your help!