Creating a steerable and hovering cube (with physics)

Hi,
I would like to create something like a car (a hovering car at this point …) by myself.

Therefore, I created a new Pawn with a Cube as the root element. Now i ran into two problems:

  1. I would like to add a constant force to the cube so that it is floating above the ground. This is why I would use the tick event to add a force into the Z direction on the cube. But as expected, it gains height over time - but I want to add a force so the distance to the ground stays constant. How can I achieve that?
  2. Additionally, I would like to accelerate the cube whenever the “Accelerate” Event is triggered. It should behave like the acceleration of the game “Micro Machines”. An impule should be added to the cube into the direction the cube faces. But this direction has to be into the worlds X-Axis. I do not want to add an impule to the ground if the cube is rotated towards the ground. I hope I made myself clear why “GetActorRotation” is wrong.

Thank you very much!

Hello @anonymous_user_4b7af1a0,

For your hovering behavior, I would highly recommend for you to watch this [tutorial][1] and follow it to create a hover component.

Once you create this hovering component, you can attach it to any static mesh or any Blueprint that has a static mesh and create a pretty convincing hovering in air behavior.

For movement, I created a bare bones blueprint which only had a static mesh component that inherited a hover component and I used the Add Impulse node to have the static mesh move in the direction of its forward vector(you could use any directional vector though).

Important Note: The static mesh you are applying the force to must be simulating physics for this to work.

Hope this answer helps,

Farshooter

thank you - the hover tutorial is almost perfect!