I'm trying to do a game like F-Zero/Wipeout, and I have no idea where to start on the physics/game dynamics, I tried with Bullet and applying force/impulse while a key is pressed.
That sort of worked, but it's far from playable, so I'm thinking of abandoning Bullet for a collision detection-only library (like Minimal OGRE Collision) (or using only Bullet's collision-detection facilities) and coding my own dynamics, now trouble is - I have no idea how to actually make the dynamics I mean that hovery effect Wipeout has, or smooth turning around corners and tilting the craft among others...
So what I need is hints and tips on: * Keeping the craft hovering (but not a static Y-only hover - see video below) * Tilting the craft while turning and making the turns smooth * Any other information about making the gameplay dynamics Wipeout-like This is the first time I'm doing something like this so any help is much appreciated.
Here's what I'd like the gameplay to be like:
Any help is greatly appreciated!
I will post a video and code from my Bullet progress later.
The above post is a mirror of my original post on GameDev.net.
I hope the guys from Aftershock/Trackverse can help!
For the hovering, I'd approach it like this. You have gravity, which applies a force downward. You have lift, which applies a force upward depending on the distance from the ground. So the closer you are to the ground, the stronger the upward force, until the upward force and gravity balance out and you stay hovering.
On a flat pice of track, everything balances out, and you stay an even distance from the ground. After you go over a jump or a bump, your forward velocity takes you further from the ground, so the upward force lessens, and gravity pushes you down until the upward force kicks in again. You might need to add some extra stabilizing code to keep the craft from bobbing up and down like a pendulum between the upward and gravitational forces.
For the roll, you could maybe approach that without using force. Just rotate the craft around the forward axis based on the turn rate.
For this message the author Jabberwocky has received kudos
if you only apply an upward force depending on the distance to the ground you'll end up with some oscillation around your desired hight. For smoothing the hight to a desired goal have a look at pid-controller: http://en.wikipedia.org/wiki/PID_controller in a nutshell: -pid stands for proportional, integral and derivative. -the proportional term alone gives you an oscillation around a desired point (like a spring). -the integral part gives a quicker smoothing to the desired point. It first increases the oscillation's magnitude but then reduces it. -the derivative term smoothes the oscillation to a constant value. this makes the process a little bit slower but reduces to problem with the integral-part at the beginning. -giving weighting factors to all these terms gives you different behaviours to smooth your signal/value to the desired goal-point
For a hovering effect you can take the vertical distance to your desired point as the proportional part, the vertical velocity as the derivative part and just ignore the integral part. Just make sure to disable the regulation while your vehicle isn't hovering but falling, otherwise you would get some really strange falling behaviour.
Tilting can be achived in a similar way. Calculate the goal-point for your roll based on your steering. Take the difference between your current roll and the desired roll as the proportional term and take your angular-momentum as the derivative term.
Use a Physics-Library to apply the Forces (angular force for tilting) and experiment a little with the weighting-factors to get a behaviour you're fine with. To speed up the motions you can either increase the proportional contribution or decrease the derivative contribution. To reduce the oscilation you can increase the derivative contribution.
For this message the author Waruck has received 2 kudos