Jump to content
• Advertisement

Air Drag Problem - Oscilation

This topic is 2564 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

Hi, I'm implementing a airplane game but I have a problem with the drag force,
For now (testing) I'm using only 2 forces
FinalForce = Thrust + Drag
Acceleration = FinalForce/mass
Velocity += Acceleration
Position += Velocity

The problem is that Drag keeps adding values to the acceleration and the object is oscillating forward and backward.

Here is my implementation:

 float speedSQ = cml::dot(velocity, velocity); //Squared speed if (speedSQ > 0.0) { // If applied to 0 then normalize gives #Inf cml::vector3f normVel = cml::normalize(velocity); //Normalized Velocity cml::vector3f Fd = (normVel * -1.0) * (0.1 * speedSQ); // Reverse Velocity normal vector multiplied by ConstDrag * speed^2 std::cout << velocity[2] << " " << Fd[2] << std::endl; // Debug output AddForceVec(Fd); //Add the drag force } //Update Transform acceleration = vecForce / mass; velocity += acceleration * _dt; // Adds the velocity cml::matrix44f_c transMat; cml::matrix_translation(transMat, velocity * _dt); transform *= transMat; 

Thrust add:

 //on Key Up player.AddForceVec(cml::vector3f(0,0,1)); 

I've tried different constants, different arrangements of code but still

Here is a debug output from (std::cout << velocity[2] << " " << Fd[2] << std::endl; // Debug output)

 //Velocity | DragForce (All in Z) 0.1 -0.001 0.2999 -0.008994 0.598901 -0.0358682 0.994314 -0.0988661 1.47984 -0.218993 2.04347 -0.417577 2.66534 -0.710403 3.21617 -1.03437 3.66356 -1.34217 3.97674 -1.58144 4.13177 -1.70715 //Releasing the Thrust 4.11608 -1.69421 3.93098 -1.54526 3.59135 -1.28978 3.12274 -0.975149 2.55661 -0.653628 1.92513 -0.370612 1.25658 -0.157899 0.572241 -0.032746 -0.115371 0.00133105 -0.802851 0.0644569 -1.48388 0.220191 -2.1429 0.459202 -2.75599 0.75955 -3.29313 1.08447 -3.72183 1.3852 -4.012 1.60961 -4.14121 1.71496 -4.09892 1.68012 -3.88863 1.51214 -3.52712 1.24406 -3.0412 0.92489 -2.46279 0.606536 -1.82374 0.332601 -1.15142 0.132576 -0.46584 0.0217007 0.221906 -0.00492424 0.90916 -0.0826573 1.58815 -0.252222 2.24192 -0.502618 2.84542 -0.809641 3.36796 -1.13432 3.77707 -1.42663 4.04352 -1.635 4.14646 -1.71931 4.07748 -1.66258 3.84223 -1.47628 3.45936 -1.19672 

Share this post

Share on other sites
Advertisement
Do you ever reset vecForce to 0?

Share this post

Share on other sites
Sorry, stupid me, I forgot to clear the forces before each update

Share this post

Share on other sites

• Advertisement
• Advertisement

• Popular Contributors

1. 1
Rutin
25
2. 2
3. 3
4. 4
JoeJ
18
5. 5
• Advertisement

• 14
• 14
• 11
• 11
• 9
• Forum Statistics

• Total Topics
631757
• Total Posts
3002140
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!