Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Question's about "sleeping" Physics Bodies

Discussion in 'Physics for ECS' started by Jarumba, Sep 1, 2022.

  1. Jarumba

    Jarumba

    Joined:
    Jul 7, 2021
    Posts:
    21
    Hello guys, I have a test case running at the moment with well over 2000 dynamic bodies rolling around in troughs. There are times when my Dynamic bodies are not moving, and I'm wondering about havok's approach on this. They are still being processed by the physics system and I don't want this for obvious performance reasons. Is there a way for me to manually set these dynamic bodies to sleep? Or do I have to manually remove the PhsyicsVelocity component to achieve this. Any help would be great.

    Losts of resources for Forum.gif

    Cheers
     
  2. Jarumba

    Jarumba

    Joined:
    Jul 7, 2021
    Posts:
    21
    Here's another note on this subject. I'm Guessing the sleep doesn't work if the angular velocity continues to move? when my Dynamic bodies get close together on my troughs they continue to spin like so:
    spinning resources for Forum.gif
    How can I stop this from happening?
     
  3. Arnold_2013

    Arnold_2013

    Joined:
    Nov 24, 2013
    Posts:
    174
    I think the Havok sleep system works when a object has not had any interaction for a few frames it will be put to sleep until it is hit again. So it will always be processed for collision detection, but not for movement update.
    I wanted to use this but noticed that trigger events also stop when a physics body goes to sleep, so I have it currently disabled.
    Stacked objects can all go to sleep, but as soon as one moves it will wake the others (if it applies a force to them when it moves). But I guess if your entire 'testcase' stops moving sleep should work.

    To remove the angular velocity you could increase the Angular Damping on the physics body.