Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
1
Question by JNSVS · Mar 13, 2014 at 08:56 AM · rigidbodyforce stop

Rigidbody - how to stop it quickly

Hi, I am playing around with a Sphere - with rigidbody added to it. I add force to it, to make it move. The body should gradually come to rest - which it does. However it takes a lot of time to do so.

I have max'ed the friction of the physics material attached to it - it helps, but the object still takes time to die out.

I have tried adding Angular & Linear Drag to it. Which causes it to slow down quicker - but when the velocity is low , it still takes forever to come to rest (or go to Sleep).

Comment
Add comment
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

4 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by jacobschellenberg · Mar 13, 2014 at 05:52 PM

Don't forget about the angular velocity.

 function FixedUpdate () {
     if (rigidbody.velocity.magnitude < .01) {
         rigidbody.velocity = Vector3.zero;
         rigidbody.angularVelocity = Vector3.zero;
     } 
 }
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
2

Answer by Eric5h5 · Mar 13, 2014 at 09:44 AM

You could do something like

 function FixedUpdate () {
     if (rigidbody.velocity.magnitude < .01) {
         rigidbody.velocity = Vector3.zero;
     }
 }
Comment
Add comment · Show 3 · 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 JNSVS · Mar 13, 2014 at 10:32 AM 0
Share

It would solve the issue for me. However I was looking for something more in terms of tweaking the Physics / Rigidbody properties.

Is there anything you could think of in lines of Physics / rigibody properties which can be tweaked via the editor?

avatar image Eric5h5 · Mar 13, 2014 at 10:37 AM 0
Share

Try the sleep velocity in the physics settings, but that would affect all objects.

avatar image Owen-Reynolds · Mar 13, 2014 at 05:13 PM 1
Share

Same trick can be extended to make it quickly slow down below some speed: if(...magnitude<1) rigid body.velocity*=0.9f; (10% off speed/frame is a lot.)

avatar image
2

Answer by RafaelCN · Mar 13, 2014 at 06:04 PM

You can do something like to slow down the object:

 public float walkDeacceleration = 5f;
 public float walkDeaccelerationOnX; 
 public float walkDeaccelerationOnZ; 
 
     if(Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0 && grounded)
             {
                 rigidbody.velocity = new Vector3(Mathf.SmoothDamp(rigidbody.velocity.x, 0, 
                                                  ref walkDeaccelerationOnX,
                                                  walkDeacceleration),
                                                  0,
                                                  Mathf.SmoothDamp(rigidbody.velocity.z, 0,
                                                  ref walkDeaccelerationOnZ,
                                                  walkDeacceleration));
             }
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 benni05 · Mar 13, 2014 at 09:44 AM

Try to increase its mass. Other than that, the moment you start your stopping motion (or you no longer apply your forces), start a timer (store Time.time in a variable, myStopMotionStartTime) and after a defined amount of time (the maximum amount of time you want it to stop, in this example 0.3 seconds) you switch the Rigidbody to kinematic and it will stop immediately.

 void Update() {
   if (Time.time > myStopMotionStartTime + 0.3f) {
      transform.rigidbody.isKinematic = true;
   }
 }
Comment
Add comment · Show 6 · 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 Eric5h5 · Mar 13, 2014 at 09:58 AM 1
Share

$$anonymous$$ass has nothing to do with it. Two objects with different masses (but otherwise identical properties) dropped from the same height will hit the ground at the same time, and stop rolling at the same time.

avatar image benni05 · Mar 13, 2014 at 10:12 AM 0
Share

Well, he didn't say that his objects are falling, I doubt it. What you describe only happens because gravitation for an object is proportional to its mass. In his case where most likely the object moves and is accelerated on a surface the same amount of force applied to 2 objects of different mass of course leads to one object moved further and for a longer time and the other, heavier will not go as far and stop earlier.

avatar image benni05 · Mar 13, 2014 at 10:15 AM 0
Share

Apart from that the solution you have suggested is probably what he needs and the easiest one to apply.

avatar image Owen-Reynolds · Mar 13, 2014 at 05:38 PM 1
Share

In the real world, a balloon will bounce off a chair cushion, but an apple won't. For real, mass matters, making the apple sink in. Same way light things can roll over a thick pile carpet. But rigidbody physics is a simplification. The chair cushion is rigid and has the exact same abstract "bounciness" for everything. And there is no "sink in more due to mass" friction.

In Unity, mass only matters for the two AddForces that divide by mass, and when hitting another moving object. It has no effect on friction and collision with frozen objects. Try it (been a while for me.) Let stuff bounce around (roll it down a ramp, etc... ,) over and over with different masses.

avatar image JNSVS · Mar 13, 2014 at 05:47 PM 0
Share

ne guides on how to bring rigidbodies to halt quicker? they keep going slowly before co$$anonymous$$g to halt.

Show more comments

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.

Follow this Question

Answers Answers and Comments

26 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

rigidbody.velocity or transform.position 1 Answer

Kinematic how to know rigidbody velocity vector? 1 Answer

Making something move relative to something else, but slower/shorter ? 2 Answers

Works in Unity, but can't be build 1 Answer

How do I make my Player object move around as if it has high drag (with no sliding), but reacts to knock-back forces as if it has low drag (with lots of sliding)? 1 Answer


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