Need help understanding speed and acceleration for "Flying mode" character setup

I have a flying character for which I’m using the character blueprint set to ‘flying mode’ and the character uses “Add Movement Input” to move.

The issue: as the speed of the flying creature increases it becomes much harder to turn the character precisely. The workaround I’ve found is to keep increasing the maximum acceleration in tandem with any increase in the maximum speed. However I’m going more for a arcade like feel and want to keep things simple, is there any other way to allow the character to move (read ‘fly’) faster without jeopardizing maneuverability? I’ve spent a lot of time fiddling with nearly every related setting (friction/air control/physics/gravity/etc) with no luck, this seems entirely dependent on max acceleration.

In all, I’ve managed to tweak my setup so the character plays nicely, but it still bothers me that I’ve had to set ‘max acceleration’ to absurdly high values (40000) to maintain maneuverability at speeds in excess of 500 (note that the default max speed is 600 for both walking and flying modes).

Any thoughts on this? I’ve also been toying with the idea of dropping the character blueprint altogether and using a pawn blueprint with offset based movement (add actor local offset) just like Epic’s flying project template. It’s just that the Character blueprint appears widely regarded as the ‘go to’ template for moving characters and even has a flying mode that seems like the right choice for my setup at first glance.

1 Like

Bump, anyone?

EDIT: OH FOR FOOKS SAKE ALL THE IMAGES HAVE NOT COME OUT IN THE POSITION OF THE POST THEY WERE SUPPOSED TO…SORRY ABOUT THAT.

If you have a flying object like a ship or plane rather than a flying humanoid character its probably easier and better to just make your own flying version from a standard pawn if you want full 360 rotation. It probably takes less effort than using the flying mode and trying to understand what all that does. Plus you don’t get those problems you seem to be having with turning at high speeds.

Unfortunately I’m not at my computer to put an image of my blueprints up but basically I fire an event in the pawns tick that controls the movement applied by the input (don’t put the input itself in the pawn put it in the player controller so the AI can use the pawn aswell without you having to make a specific AI version, then pass the input from the controller to the pawn).

I’ll try to write a simple walkthrough to get you started, I can always show you my blueprints when I get home later on. (in fact I’ve just managed to install UE4 on a rather splendidly **** computer so i’ll post some screenshots, bear in mind though these arn’t my blueprints they’re just me doing them as I write this as a visual aid)

you’ll need some float variables in your pawn:

-Pitch Input
-Yaw Input
-Roll Input
-Thrust Input
-Pitch Speed
-Yaw Speed
-Roll Speed (optional if you want the roll speed to be different to the turn speed)
-Thrust speed (personally I make a throttle that does some calculations to get the thrust speed but for simplicities sake we’ll just use a constant value)

-Assign default values to pitch speed, yaw speed, roll speed, thrust speed

The general idea is that input values read from 0 to 1, you then multiple the input value by the (for example) pitch speed to get the amount of pitch applied, then add this value to the pawn by using either the blueprint node ‘SetTorque’ or alternatively (and the one I use as it seems to work better) ‘setAngularVelocity’. All the variables ‘pitch speed’, ‘roll speed’ etc are essentially the maximum amount of turn that can be applied per frame, so if the player was holding the pitch axis on the controller all the way down the pitch input value would be returning the value of ‘1’, which applied to the ‘pitch speed’ would give you the maximum pitching speed.

Hope this waffle is making sense so far…

We’ll do the player controller first:

-Create your axis and button mappings in the project settings. Surprisingly I don’t have a joystick/gamepad at work so I’ve just mapped keyboard controls :slight_smile:

-Create the input events in your controller blueprint and send the values to the pawn. I also have a pawn reference variable that gets set at ‘Begin Play’ in the player controller that you’ll need to cast to as you’ll need that to send the custom input values to your custom pawn.

e.g.

Get the pitch axis input then store that value in the pawns variable ‘pitch input’

-Do that for all your axis and buttons

Now to the pawn:

-Create a function (you can do an event instead but I prefer functions to keep it clean and manageable) called something like ‘SetTurnMovement’.
-Open the function and in here you’ll do all the code for turning the ship
-You basically want to create a vector that is made from the values of pitch, yaw and roll then add them to a node that uses physics to turn the flying object. Worth ticking that ‘add to current’ on the ‘Set Physics Angular Velocity’ node to begin with as you’ll probably find your values are to low to move the object and it’ll look like nothing is working, that’ll take some tweaking so best to start from a place where the ship actually turns so you know it’s all working before you fine tune the values.

Now in the main blueprint of your pawn add a ‘tick’ event and make that fire the function you just created:

-Also make sure that in the components part of the pawn blueprint you set the component that is moving (i assume a static or skeletal mesh) is set to ‘simulate physics’. Also you’ll find all the other settings you need in there to control the handling of the flying object at the physics level, for example angular damping which will make it harder to turn/slow the ship down quicker when turning. All the inertia and spacey movement type stuff basically.

I can’t be bothered in all honesty to do the thrust aswell as it’s now lunch time I’ve spent so long putting this together, it’s just the same thing as the turning function but put in your ‘thrust input’ and ‘thrust speed’. Also instead of ‘Set Physics Angular Velocity’ node use either the ‘add impulse’ or ‘set physics linear velocity’ nodes.

1 Like

^
Thanks a lot for that wonderfuly detailed explanation! I’m sure that will benefit a lot of people.

Looks like my initial suspicion that salvaging the character blueprint for a flying creature would be too clunky was about right. Out of curiosity I tried digging through the PHYS_FLYING character mode in C++ but as you pointed out the in-built flying system has very specific behavior and tweaking that to fit my needs is over-complicating things.

While I’m still using the character template for now (acceleration=40000, yuck) at some point down the line I’ll migrate to a pawn based model.

what after that massive explanation, installing the engine and taking screen shots for everything you’re going to try this out down the line instead of dropping everything you’re doing and getting straight on it, you sod :wink:

I suspect it’s more intended for humanoid characters so you’d probably end up overriding loads of stuff that is hindering you. It was like that on UDK aswell back in the day, was easier just to start from scratch sometimes rather than reverse engineer half the stuff :slight_smile:

bear in mind with the big numbers, the unit scale is the lowest I’ve ever seen on a game engine so you’ve got pretty much a couple of extra digits on every measurement. If you were using Unity that number would probably be more like 400. It keeps messing me up when I’m placing things and I keep thinking 10 is 10 meters when it actually is 10cm :slight_smile:

You know what I’ve missed a pretty major part out there, if you set the blueprints up like you’ll get some lovely confusing turning movement :slight_smile:

You have to include the forward, right and up vectors of your flying pawn when creating the vector to apply to the angular physics node so the vector is in local rotation rather than world rotation. I’ll go into more detail if you ever need me to further down the line just let me know :slight_smile:

Understood, I do have the same vectors plugged in to the character based BP approach as well, should be easy to rewire things up. Thanks again!

Good man, saves me waffling more nonsensical waffle :slight_smile: