Thursday, 12 July 2018

Hover Car: Lift-Off



I was inspired by Switcheroo Jam 2018 to continue practicing 3D modelling - but wanted to create something I could bring to life with code.

Unity3D, C#, Blender.



I always liked the idea of modelling my car and having a reference I could inspect in real life rather than solely from image results sounded a welcome change.

This was my first attempt modelling something which would need to be a precise replica of a real life source, rather than using a source for inspiration. This increased the time it took to produced the model significantly.

I had implemented a car-style 'drive controller' script before, so when it came time to model the wheels I decided to add 'hover jets' instead to explore a different challenge and for a bit of fun!

front view
side view
rear view


To calculate altitude and detect any objects below the car, I raycasted downward from each thruster position. 
If a raycast detects an object within a certain distance below the car, a force is applied at the position of the detecting thruster, lifting the car.

First try wasn't too impressive.

Amending behaviour to make the upward applied force relative to the distance above the ground (closer to detected object = stronger lift) and adding checks to apply an inverted, downward force if the altitude of the thrusters became greater than that of the car body prevented it from rolling to too extreme an angle for the thrusters to keep it airborne.

(of course, detecting downward does need to be done relative to the local position of the thrusters!)


After some tweaking I achieved the bobbing behaviour I intended... if still a little over dramatic.


The checks have since been corrected to make the idle vertical motion more subtle. For an early version the car responds to obstacles relatively well, remaining upright and stabilising quickly after.



The behaviour while falling from a higher object will need to be smoothed to give more believable 'thrusters', but that's for next time!