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 Ishkur · May 30, 2013 at 05:31 AM · rigidbodycolliderrigidbody-collisionsleep

Rigidbody sleeping prevents collision detection

Hello, I'm trying to detect the collision between two game objects. The first object is a static sphere collider with a rigidbody attached, on a user defined layer and no gravity enabled.

The second object is a user controlled sphere collider (parented) with no rigidbody attached and on the same user defined layer as the static collider.

I think because the first static game object doesn't move, its rigidbody goes to sleep and stops detecting collision with the player.

And so I've added a rigidbody to the player on the parented sphere collider. But I think because the rigidbody is parented to the player and I use a character controller to move the player, that rigidbody is also considered nonmoving and also goes to sleep.

How am I supposed to detect collisions now? Is there a certain best practice to follow when creating my player prefabs in terms of components and parenting?

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
4

Answer by TonyLi · May 30, 2013 at 02:00 PM

You may have already read through this page, but it explains all the combinations that work: https://docs.unity3d.com/Manual/RigidbodiesOverview.html (Was: http://docs.unity3d.com/Documentation/Components/RigidbodySleeping.html)

If your first object is static and you just want to know when player (second object) enters its bounds, you could remove the first object's rigidbody and make it a static trigger.

I don't think the player's rigidbody child should fall asleep.

Are your layers correct? Double-check Edit > Project Settings > Physics to make sure collisions are enabled.

To get verification that sleeping is the real problem, you could add a temporary test script to keep the rigidbodies awake. Something like:

 void Update() {
     if ((rigidbody != null) && rigidbody.IsSleeping()) {
         rigidbody.WakeUp();
     }
 }

If they still fail to register collisions, then it's not a sleep problem.

Comment
Add comment · Show 4 · 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 Ishkur · May 30, 2013 at 06:33 PM 0
Share

Thanks for the reply! I've checked that the layers and selected properly and their interactions were set alright.

Before reading your answer, I just added a 3rd rigidbody to the parent object and that fixed the problem.

I haven't followed through to verify if the rigidbody sleeping of the child collision mesh component was the problem.

avatar image TonyLi · May 30, 2013 at 07:40 PM 0
Share

To help others who might be reading this with a similar problem, what about the third rigidbody fixed your problem?

avatar image aaonurdemir · Aug 26, 2016 at 08:11 AM 0
Share

Link is broken.

avatar image TonyLi · Aug 26, 2016 at 12:48 PM 0
Share

Updated link.

avatar image
0

Answer by Obi02_ · Dec 11, 2018 at 07:01 AM

I know this is an old thread, but I had a similar problem, and to fix it I did the following:
On the rigidbody I set
- collision detection to continuous
- sleeping mode to never sleep

and it seemed to work for me.

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 NathanJSmith · Aug 20, 2019 at 09:41 AM

You can set Rigidbody.sleepThreshold to 0 to disable rigidbody sleeping feature.

     m_Rigidbody = GetComponent<Rigidbody>();
     m_Rigidbody.sleepThreshold = 0.0f;


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 amitDklein · Sep 14, 2020 at 05:22 PM

You can use

 void Start()
 {
 this.GetComponent<Rigidbody>().sleepThreshold = 0.0f;
 }

this worked for me

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.

Follow this Question

Answers Answers and Comments

17 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

Related Questions

Rigidbody not sleeping 1 Answer

rigid bodies passing through one another. 1 Answer

Rigidbody not colliding with walls 1 Answer

Rigidbody Precise Colliders 1 Answer

How to make an object 'push' my character out of the way upon collision? 0 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