x


How to cancel aerodynamic drag?

I have an airplane with my script, the main problem is that I use those 2 formulas :

   L = (p*Mathf.Pow(transform.InverseTransformDirection(rigidbody.velocity).z*3.6,2)*A*Cl)/2;

for the lift and

Dx = (p*Mathf.Pow(transform.InverseTransformDirection(rigidbody.velocity).x*3.6,2)*A*Cd)/2;

rigidbody.AddRelativeForce(-Vector3.right*Dx);

Dy = (p*Mathf.Pow(transform.InverseTransformDirection(rigidbody.velocity).y*3.6,2)*A*Cd)/2;

rigidbody.AddRelativeForce(-Vector3.up*Dy);

Dz = (p*Mathf.Pow(transform.InverseTransformDirection(rigidbody.velocity).z*3.6, 2)*A*Cd)/2;

rigidbody.AddRelativeForce(-Vector3.forward*Dz);

for the drag. I set the drag of my rigidbody to 0.1 and try to use those formulas, but airplane continues moving with momentum/inertia

No idea? :D

more ▼

asked Dec 28 '11 at 09:38 AM

anwe gravatar image

anwe
114 31 34 38

Well, canceling the drag is simply to set "drag" to 0 (zero). But I guess that's not what the problem really is? You want to cancel the first law of physics, the one about momentum?

Dec 28 '11 at 03:31 PM TowerOfBricks

yes, here we are, cause I add the force to my airplane, but when I use addrelativetorque it continues to go straight forward, even if it's rotated

Dec 28 '11 at 05:36 PM anwe

Ah, well, torque doesn't affect movement unless there is a collision. You could try setting rigidbody.velocity to transform.forward * someSpeed to get it to always move in the forward direction.

Dec 28 '11 at 05:39 PM TowerOfBricks

yes, u'r right, the problem is that it conserves its momentum, that's the matter

Dec 29 '11 at 09:26 AM anwe
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Hmmm, i have anti-grav ship which had this annoying momentum too, so i did something like this:

var MaxSpeed : float = 1700000;
var ActSpeed : float = 0;

function FixedUpdate() {
    verMovement = Input.GetAxis("Vertical");
    rigidbody.AddForce(transform.forward * ActSpeed * Time.deltaTime);
       if (verMovement && ActSpeed < MaxSpeed) {
         ActSpeed += 2500;
       }
       else if (!verMovement && ActSpeed >= 1500){
       ActSpeed -= 1500;
       }
       if (ActSpeed < 0){
         ActSpeed = 0;
       }
}
function OnCollisionEnter (StrHit : Collision){
    rVelocity = rigidbody.velocity.magnitude * 3.6;
    if (StrHit && ActSpeed > 0 && StrHit !== gameObject.tag == "Enemy"){
       ActSpeed -= 900 * rVelocity;
    }
}
function OnCollisionStay (WeakHit : Collision){
    rVelocity2 = rigidbody.velocity.magnitude * 1.6;
    if (WeakHit && ActSpeed > 0){
    ActSpeed -= 200 * rVelocity2;
    }
}

Hope it helps... somehow ^^d (rigidbody is 60u heavy, and is set to drag = 3)

more ▼

answered Dec 29 '11 at 10:07 AM

zero3growlithe gravatar image

zero3growlithe
67 17 23 26

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5088
x287
x68
x24
x5

asked: Dec 28 '11 at 09:38 AM

Seen: 515 times

Last Updated: Dec 29 '11 at 10:22 AM