• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by spaceshooter · Feb 23, 2011 at 01:22 PM · physics

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!

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image _MGB_ · Feb 25, 2011 at 05:12 PM 2
Share

I think you'd have to apply your own drag forces for you to be able to reliably calculate this.

avatar image Alec-Slayden · Feb 25, 2011 at 08:53 PM 3
Share

http://www.grc.nasa.gov/WWW/$$anonymous$$-12/airplane/termv.html all I got sorry =\

avatar image Peter G · Mar 01, 2011 at 01:50 AM 0
Share

That link is really helpful

avatar image Proclyon · Mar 01, 2011 at 08:46 PM 0
Share

You should get +5 just for getting involved with NASA

5 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Bravini · Feb 27, 2011 at 02:56 PM

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.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bravini · Feb 27, 2011 at 02:57 PM 0
Share

or you can use http://unity3d.com/support/documentation/ScriptReference/Rigidbody-maxAngularVelocity.html

avatar image Peter G · Feb 27, 2011 at 03:16 PM 0
Share

Actually Bravini, you code won't work. You are comparing a Vector3, velocity, to a float, maxVelocity. $$anonymous$$aybe you meant velocity.magnitude, but that still leaves you to fix the statement inside the conditional blocks.

avatar image Bravini · Feb 27, 2011 at 04:28 PM 0
Share

thanks for the heads up, just fixed. That's what happens when you're too lazy to actually open the project and look :]

avatar image Bunny83 · Mar 01, 2011 at 03:11 AM 0
Share

You're just limiting your speed in x direction, Unity have a nice function that can clamp a Vector3: Vector3.Clamp$$anonymous$$agnitude().

avatar image Bravini · Mar 01, 2011 at 03:52 PM 0
Share

yeah, it works the same too, but using variables you can set different limits for forward and backward in the inspector or in runtime with boosters, in case you want to move a car or a spaceship with thrusters.

avatar image
0

Answer by Alex Hogan · Feb 27, 2011 at 09:46 PM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Peter G · Feb 28, 2011 at 12:49 AM 0
Share

The problem is that drag isn't clamped to 1, its clamped to infinity and that will completely stop your object. So the challenge is deter$$anonymous$$ing the proper drag to stop the object from accelerating, but not slow it down any.

avatar image
0

Answer by _MGB_ · Feb 28, 2011 at 08:11 PM

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by robert 4 · Mar 02, 2011 at 11:51 AM

http://unity3d.com/support/documentation/ScriptReference/Rigidbody-angularVelocity.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by AVividLight · Mar 02, 2011 at 06:34 PM

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...

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

2D 360 degress platformer example needed 0 Answers

ignore forces except gravity? 1 Answer

How to make a system that will let elements interact with other elements? 1 Answer

Accessing a parent's other children 1 Answer

Physics Materials: Ice, Wood, Metal, Rubber 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges