• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Hovercraft Physics

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1ProgrammerGuy123  Members

Posted 21 July 2012 - 01:47 PM

I'm trying to implement hovercraft like physics into my game but I need help. An improtant thing to note is that the hovercraft will be pretty high off the ground unlike realistic hovercrafts. After searching and asking questions I arrived at this source code:

       double g = 9.8d; //gravity
double m = 1.0d; //mass
double fMax = 15; //maximum upwards force
double idealHeight = 100; //ideal height the craft should be off the ground
double v; //velocity
void Update() {
double h = Math.Abs((craft.Y + craft.Height) - ground.Y); //determin the craft's height from the ground.
double a = (g - f(h)) * m; //acceleration
v += a; //velocity
v = MathHelper.Clamp((float)v, -15.0f, 15.0f); //make sure the acceleration doesn't get out of hand
craft.Y += (int)v; //assign the velocity
}
double f(double h) { //this function return the amount of upwards force
return Math.Max(0, h * (g - fMax) / idealHeight + fMax);
}


One cunfusing thing to note is that my game is 2D with (0, 0) being the top left corner of the window and (100, 100) being accrosed and down 100 pixels. This is why I have the Math.Abs(craft.Y + craft.Height) - ground.Y whole thing.

Now the problem:
This code works but the craft just goes up and down up and down up and down enlessly. I would like the craft's velocity to diminish over time to equal out with the idealHeight. Like this picture shows.

How would I do that?
Thanks.

### #2ZBethel  Members

Posted 21 July 2012 - 02:42 PM

The term you're looking for is spring damping.

http://en.wikipedia.org/wiki/Damping
http://www.myphysicslab.com/spring1.html (more useful, IMO)

Basically you need to apply a friction force against the oscillating spring force that you're applying to the hovercraft.

### #3ProgrammerGuy123  Members

Posted 21 July 2012 - 07:53 PM

Ah yes thank you. Very informative links.

### #4GeekWrath  Members

Posted 02 October 2012 - 04:53 PM

I am working on what appears to be an very similar system and have used the same formula as you did. I was hoping you could enlighten me with what formula or code you used to achieve the required damping.

Thank you in advance for any assistance you can provide.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.