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
0
Question by invicticide · Jul 11, 2012 at 05:01 PM · physicsrigidbodysleep

Why are my Rigidbodies not sleeping?

I have a zero-gravity scene and some Rigidbodies floating in space that I can kick around. They have some drag, so once you kick a body it'll float for a bit and then come to a stop. By "kick" I mean applying a single, one-off force. I am not applying any subsequent forces or forces over time.

In PhysicsManager, I've set the Sleep Velocity and Sleep Angular Velocity both to 1. My understanding is that once a body's velocity falls below these thresholds, the body will go to sleep.

The behavior I'm actually seeing is that my bodies remain awake until both their velocity and angular velocity have reached true zero, and then for several seconds afterward. Some bodies seem to remain awake indefinitely. I can inspect such a body in the scene and see that it is not in contact with anything; and using a debug display to show its current rigidbody.velocity, rigidbody.angularVelocity, and rigidbody.IsSleeping, I can see that both properties are true zero, and IsSleeping is FALSE.

I can't for the life of my figure out why?

In searching around for answers, the most common suggestion I saw looks like:

 // on the RigidBody
 void FixedUpdate()
 {
     if(rigidbody.velocity.magnitude < someSleepVelocity)
         rigidbody.Sleep();
 }

Seems simple enough in theory, but my problem is that I have a very large number of rigid bodies spread throughout the scene, so running this code on all of them all the time becomes extremely performance-prohibitive. And besides, it seems redundant, no? Isn't this exactly what the PhysicsManager sleep thresholds are supposed to be doing?

Comment
Add comment · Show 2
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 OperationDogBird · Jul 11, 2012 at 05:41 PM 0
Share

if you have a debug on this script, and this script is attached to all the rigidbody objects you will have no way to tell which log is from which object. Seems like a bad use of RB sleep as well, probly be much more efficient to just let them keep floating rather than running fixed update on X amount of objects.

avatar image Matt-Downey · Jul 15, 2012 at 03:18 AM 0
Share

I would try turning max angular velocity to 1 (or maybe 0.5) as well and see if the game works correctly (simply for debugging reasons).

Also, maybe try different Physics pushes like for forcemode use impulse ins$$anonymous$$d of velocitychange or vice versa. http://docs.unity3d.com/Documentation/ScriptReference/Force$$anonymous$$ode.html

As I recall, if any script is used on the object, it will wake up (maybe it's just physics script, idk).

0 Replies

· Add your reply
  • Sort: 

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

6 People are following this question.

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

Related Questions

How to stop rigidbody.sleep() 2 Answers

Rigidbody not sleeping 1 Answer

How do I change force of gravity for a single object? 4 Answers

Getting 'Real' behavior through physics settings 1 Answer

Move armature rigidbody character 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