Jump to content
  • Advertisement
Sign in to follow this  

how to implement Intertia

This topic is 2030 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So i have a jet.

I make a force that moves it. but when i set it to 0 (this force) the jet stops, but it shouldn't, it should at least move with this force(because i didn't include drag force )


but i have no idea how to implement intertia there.


lets assume i got drag force (lets call it drag_force)

all forces are vectors with length of acting force and its direction in my case ;]

if this helps you here is the code


void __fastcall TVehicle::ProcessFrame()



    double l;

l = timin->getElapsedTime();

float dt = float(l);

if (dt <=0 ) return;

float Front_force = Throttle_to_force( Throttle );   //thrust force val

float Q = eGForce * mass;    // gravity force val

  ThrustForce_vec  = YPRangle.rf;                 //thrust force direction

  pos_from_plane_to_planet_center = vectorAB(pos, zero);

  GForce_vec  = Normalize( pos_from_plane_to_planet_center ); //g force direction

GForce_vec 		= vector_multiple(GForce_vec, Q);
ThrustForce_vec = vector_multiple(ThrustForce_vec, Front_force);

result_force = vectors_add(GForce_vec, ThrustForce_vec);//add forces

		   //divide vector by float
Acceleration = result_force / mass;      // a = F / m

dk = ( dt*dt );

accvel = Normalize( Acceleration );

Translation = vector_multiple(Acceleration, dk);
Translation = vector_multiple(Translation, 0.50f); //(a * t^2 )/ 2
s = V * dt;
accvel = vector_multiple(accvel, s);         //  V0 * t   => convert it to vector
	 Translation = vectors_add(Translation, accvel);   //add vectors v0t + (at^2)/2   => s= v0t + at^2 / 2
		   t3dpoint rp = vectors_add(pos, Translation );      //move to new position
		   if ( rp.y < 0 ) rp.y = 0.0f;
			pos = rp;
                                                      // v = s / t
	  V = n3ddistance(pos,old) / dt;  // s = V * t 						v=s/t

											old = pos;  //save position


as you can see i use result_force

this need to be changed to intertia but how? ;x


like always i attach a video


by the way i have problems with calculation velocity properly but as soon i will deal with this problem and add some things i will make a new post ;P

Edited by ___

Share this post

Link to post
Share on other sites

Start with Euler integration:

acceleration = force/mass;
velocity = velocity + acceleration * dt;
position = position + velocity * dt;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!