# Hovering ship

Hi all,
I would like to set up an hovering vehicle to make a Wipeout like race game . The first time I used wheeled vehicle with invisible wheel, not so bad result but…

I tried to make a real hovering system with the UFO blueprint that is in the content example of UE4 . I copy blueprint and set the camera follow right, the ship turn good and other stuff… but the UFO that I use is a flyng Actor, it do not hover above the ground, and this is what I want to do .

“Youhou I fly !! But I should just hover on the road”

Do someone could indicate me a way to turn on gravity and hovering for my UFO ?

It almost seems like you’d want some sort of spring constraint on your UFO. Basically, a spring with a length equal to the max height from the ground you want your ship to float, maybe with lowish damping so you can fly upward off of ramps and stuff.

No idea if UE4 can accommodate this method, but if it can, you basically just want a spring between your ship and the terrain, and update the position of the spring on the terrain every time the ship moves. Something like that.

I would add an action that runs every tick (yeah, you have to do something like that) that checks the distance between UFO and ground (using a trace of some sort) and adds an upwards force proportional to the inverse of the square of the distance between UFO and ground, and proportional to the downwards velocity of the UFO. This ends up being a kind of PID controller for the height of the UFO. Then, add a downwards force, such as gravity, and crank up the trace and down-velocity proportions to make it hover at the height you want.

Z-enzyme is already working on a similar project:

Thanks all for your reply, Ok I’m a noob but I’ll try to use the tick, the springs arm and other stuff you told me

Yep, this would be approximating a spring constraint, and give you the desired effect.

@OP, check out Verlet Integration, you can build a simple spring like @jwatte describes and it doesn’t require complex math.

Well Verlet integration is for cloth and things like this (rope, cable…) I don’t understand why using it could help in my case ??

I don’t even know ho to simply add gravity to my actor !
Mathematics don’t afraid me so much, but I don’t know how to tell UE4 :

“Please take this ground distance and add me an upward force man !”

I create a Spring Arms and I try to copy what Z-enzyme do, but we don’t start our project by the same way, he use 4 axis where I just have an actor Oo I wrote on him topic for a kind of tutorial because I’m sooo newbie .

Verlet is used in cloth because each link in the cloth acts like a spring. The constraint of staying near the ground acts like a spring for your case, too.

1. Note that the square-of-the-distance inverse force is important, to avoid a spring that resonates too much.

2. Here’s a suggested blueprint. I haven’t tested it, so it may need adjustments. You may want to create a new trace channel for “repels hovers” or something.

1. You probably want to create your own Pawn class that runs the hover simulation, and your own Controller class that sends input to that Pawn

2. If you want the hover to conform to terrain (lean up when going uphill) you need either more traces, at the four corners of the hover, or do something smart with the normal of the hit you find with the one trace.