How to fix a z axis value of character?

Hi there :slight_smile:

I’m going to make a airplane(Character) fly in specific height(z axis).

and Sometimes I wanna make it fly little lower and also higher than the fixed height.

 ------------------ higher height

`---------------------------------- Fixed Height

 ------------------ lower height

Like this.

So How can I script these things?

Thank you so much :slight_smile:

Hey arrietty!

First of all, you shouldn’t be using character class for an airplane, unless you are doing some kind of transformers game. Use pawn instead.

So when you go up/down with the plane, will it eventually come back to the fixed height? I assume so.

You need to have input axis up/down to add force.
ForceZ = InputAxisĂ—Speed*GetWorldDeltaS

Note: speed MUST be really, REALLY high value, something like 10 million. Experiment with it.

To get it back to fixed height, on tick, also add force.
ForceZ = (0-LocationZ)Ă—GetWorldDeltaSĂ—GetBackSpeed

Notes: GetBackSpeed needs to also be really high value and the pawn Z world location must be 0.

Hope this helps, cheers! :slight_smile:

Np! Also… Would ya be so kind to add some karma, trying to get the badge this week? :wink: