# Calculate Terminal Velocity

The scenario is: 2D, movement on XY. No Gravity, object has a drag value of .6 and has a force of vector.up * 5 being applied to it (FixedUpdate(),Forcemode.Force).

How would I calculate the terminal velocity or max velocity of this object ahead of time?

Looking at the normal formula, I don't really have a projected area of the object or fluid density in this case. I'm also not really sure if the rigidbody.drag value is the same thing as the Drag Coefficient in this formula.

Thanks!

i'm not very good at math, but you can limit the max speed of you rigidbody, so you know beforehand what it will be. Code is as simple as:

``````public float maxVelocity;

void FixedUpdate() {

if (rigidbody.velocity.x > maxVelocity)
rigidbody.velocity.x = maxVelocity;

//now for the reverse direction
else if rigidbody.velocity.x < -maxVelocity )
rigidbody.velocity.x = -maxVelocity;
}

``````

Tested code, I use this to limit my AI chars from moving too fast.

Rather than calculate it, why not set it?

Make a BehaviourScript with two parameters - terminal velocity and a threshhold.

In update, or maybe LateUpdate, check the rigidbody's velocity.

If it's within the threshhold, start increasing the drag.

Use InverseLerp with the ThreshHold value and the TerminalVelocity value to get the amount of drag you want to add - just make it go to one as it approaches the terminal velocity.

Expanding on my comment above... Set the Unity body drag to zero and then calculate and apply your own drag forces - it's not too hard. Then you know the exact values used and can plug them into this equation

I'm not sure if it will help, but you could modify my code, to get the speed by knowing the distance and speed...

``````    //Written by/for Gibson Bethke

var Counter : float = 0.0;
var maxCounter : int = 0;
var terrain : Terrain;
var Player : Transform;
var Guitext : Transform;

function Update () {

var up = Player.TransformDirection (Vector3.up);
var hit : RaycastHit;
Debug.DrawRay(transform.position, -up * 5000, Color.green);

if(Physics.Raycast(Player.position, -up, hit, Mathf.Infinity)){
Counter = Vector3.Distance(Player.position, hit.point);

if (Counter > maxCounter) maxCounter = Counter;

if(Counter <= 10){
Guitext.guiText.text = "You're at ground level    Top Height: " +maxCounter;

}else{
Guitext.guiText.text = Counter+ " Meters";

if(Counter >= 10){
Guitext.guiText.text = Counter+ " Meters       Top Height:   " +maxCounter+ " m";
}
}
}
}

``````

Or just make a 2d image with even number intervals and time it...