Download

My 'True' Hover-Tank Lives!

You have no idea how long it has taken to get this working, I’ve been trying to create spring physics and all sorts but I think I’ve finally (well, nearly) nailed it. I’ll explain briefly what I’m doing below. There will eventually be a C++ class for this when all functionality is working!

YouTube Video

http://i239.photobucket.com/albums/ff29/thejamsh/8f2f0b403cce50eb603acd4842b1f980_zpsa9e99e51.png

So the premise is to create a true hover-vehicle class, not like the hack that was the Manta in UT3, but one that actually uses velocity to maintain it’s altitude. The game I’m basing the physics on is Battlezone II, an awesome retro game from 1999 [see video here]](http://www.youtube.com/watch?v=dlBJaKSSOXU&list=PLXBGeAc2Oh2g_AmQzoNMFo4o3yNDC2xiJ) I’ll add cool guns n’stuff later.

Essentially the code does some cool things, it does two line traces which are shown by the debug lines above. The green trace is always projected directly downwards in world space from the craft, ideally the center (I’ll likely use actor location later). This trace finds the ‘floor’ beneath the craft, and calculates the altitude of the craft by the length of the trace. It also does another trace (seen in red), which is aligned to the velocity of the craft, and it’s length is relative to the crafts velocity ‘length’ (e.g., faster = longer).

The code then blends between these two different impact points to determine the crafts current altitude, and what the up-coming terrains altitude is, and adjusts the craft height accordingly, but all based around a pre-set altitude that you can define. Rather than setting the crafts altitude via a direct position adjustment, it actually alters the current velocity. Currently it’s not ‘perfectly’ accurate, because the gravity value is just a constant that doesn’t reflect the worlds gravity. Unfortunately there’s no way to get world gravity as a value in blueprint, so I just use a float at the moment (-9.8). I also have nothing to stop it wandering off in all directions, as you can see in this video below :stuck_out_tongue:

Still need to add some form of damping to prevent the ‘bounciness’, but it’s a step closer to my goal. I’ll attempt to get some kind of player control working next, so I can get proper feedback on how it really feels. I’m currently still using the beta version of UE4 and haven’t got my hands on the public build yet, when I do I’ll start work on the C++ version, which will probably be a bit less… bouncy.

As you can see the altitude cut-off isn’t quite working yet, but I hadn’t tried the cliff drop-test until hitting record in Camtasia:

Super interesting read, I would love to know more about the logic behind your replication of physics, I am going to have a go at similar hovering tank logic, the 2 traces to figure out where it’s heading and current altitude is a great starting point. Curious if you handled rotation with torque and if you did all transformation adjustments with force/impulse/torque, if so how did you get it to stay upright (get the ground normal and convert that to a rotation vector you could use?)