- Home /
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
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?
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
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.
yes, u'r right, the problem is that it conserves its momentum, that's the matter
Answer by zero3growlithe · Dec 29, 2011 at 10:07 AM
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)
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Limit object rotation on drag it 0 Answers
Banking and momentum 1 Answer
Drag camera with two finger swipe 1 Answer