Mathematically it should be:
Quote:
y(t) == y(0) + v(0) t + (1/2) g t2

where:
* y(t), height depending on time;
* y(0), starting height;
* v(0), starting speed;
* g, acceleration ( gravitational acceleration g is 9.98 on earth, 3.73 on mars);
* t, time.


In the example of a falling panel:
Code:
if (falling == true) {
  panel.pos_y = fallheight + (0 * falltime) + 0.5 * 9.98 * (falltime*falltime); //gravity formula, change (0 * falltime) for giving an initial speed
  falltime += time_step; //falltime is counting
}

if (falling == false) {
  falltime = 0; //reset falltime
  fallheight = panel.pos_y; //record height as long as we're on ground, can then be used as initial height when in the air
}


Last edited by Joozey; 12/17/08 16:44.

Click and join the 3dgs irc community!
Room: #3dgs