# Basic aerodynamics questions

Hi all, New to unity. Does unity have any basic aerodynamics in its physics model?

There are a few things that I am specifically interested in... take a sky diver... if I make a physical skydiver mesh... and arch his back in the traditional manner for skydiving, will wind resistance cause him to orient properly when falling down?

Similarly, the feathers on an arrow shot from a bow cause the arrow to align to its direction of flight. (It's basically a "center of pressure" to "center of mass" calculation).

Maybe my question boils down to this: does unity understand center of pressure?

Thank you so much!

Ryder

Success Update: CpScale is what generates the artifical aerodynamic drag force (always negative) . Drag decreases when it "flies true" (like an arrow going the right way). Flynn in forms was indispensible in developing this.

``````    var Cp: float; // The y location of the center of pressure
var Cg: float;  // The y location of the center of gravity/mass

function Awake(){
rigidbody.centerOfMass = Vector3 (0, Cg, 0);  // set new center of mass
}

function Update () {

}

function FixedUpdate(){
// find the deviation of the nose from the direction of flight
var dif = Vector3.Angle(rigidbody.velocity,transform.up);

// calculate the size of the center of pressure force based on angle (maximum of -0.5 at 90 degrees)
var CpScale = ((Mathf.Abs(dif -90) - 90)/ 720);

//apply force to the center of pressure

}

``````

Unity does allow you to alter centre of mass and it does have air resistance drag, to get the behaviour you describe you can move the centre of mass of the object behind it (the place where all the physics reactions are acted upon by default) and then use your own gravity script using the add force at point function. If you add the gravity force at the front of the arrow it'll tilt toward the direction its falling in.

Unity doesn't have any concept of air pressure, nor wind resistance (besides a friction force which "kind of" simulates wind resistance, amongst other things).

That's not to say you can't add these things in yourself though via scripting

I'm fairly certain the answer is no. Unity uses the PhysX Engine, giving the capabilities listed in the Unity Physics Manual page.

Given that most Colliders are based on simple geometric shapes, I don't see how Unity would compute center-of-gravity. And the Mesh Collider appears to only care about friction and bounciness - hopefully bounciness wouldn't apply to any skydivers. :) (B-license here).

There's no standard common physics real time engine around that calculate aerodinamics around. That's engineering stuff that requires complex calculations.

This doesn't mean you can't code a simplified version of your own, exactly like it happens with driving simulation games, but you must be able to crunch some math and geometry.

If you make a cube, and use 0 for drag and angular drag, it will fly through the air with no resistance at all. So a brick and a plane will fly equally well. ;) Those are the only two parameters you get for this sort of thing; shape doesn't enter into it. In order for real-time physics to run fast, the physics model has to be drastically simplified compared to real life...generally you don't care when most of the time you're just doing things like making crates fall over. Anything complicated needs to be custom-scripted.

The basic answer is "no", but Unity can be taught to understand Center of Pressure via code.

AddForceAtPosition can be used to apply a force to any part of a rigidbody, and if properly constructed, will act like aerodynamic pressure. Flynn (in forums) was instrumental in getting past specific coding roadblocks. (some important code below is his)

The variable CpScale is what generates the artifical aerodynamic drag force (always negative) . Drag decreases when it "flies true" (like an arrow going the right way).

``````var Cp: float;   // The y location of the center of pressure
var Cg: float;  // The y location of the center of gravity/mass
function Awake(){
rigidbody.centerOfMass = Vector3 (0, Cg, 0);  // set new center of mass
}

function Update () {
}

function FixedUpdate(){
// find the deviation of the nose from the direction of flight
var dif = Vector3.Angle(rigidbody.velocity,transform.up);

// calculate the size of the center of pressure force based on angle (maximum of -0.125 at 90 degrees)
var CpScale = ((Mathf.Abs(dif -90) - 90)/ 720);

//apply force to the center of pressure