Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  ObiRigidbody prevents Rigidbodies from sleeping
#2
Hi!

Accessing the velocity property of a Unity rigidbody will keep it awake, even if you don't modify its velocity at all, or set it to zero. We reported this to Unity quite a while ago but it seems it's still an issue. See my thread in the Unity forums regarding this issue:
https://forum.unity.com/threads/rigidbod...o.1052369/

You can work around it in Obi, by checking whether the rigidbody velocity is above a threshold before assigning it. Open up ObiRigidbody.cs, and make sure its UpdateVelocities method looks like this:

Code:
        public override void UpdateVelocities(Vector3 linearDelta, Vector3 angularDelta)
        {
            // kinematic rigidbodies are passed to Obi with zero velocity, so we must ignore the new velocities calculated by the solver:
            if (Application.isPlaying && !(unityRigidbody.isKinematic || kinematicForParticles))
            {
                if (Vector3.SqrMagnitude(linearDelta) > 0.00001f || Vector3.SqrMagnitude(angularDelta) > 0.00001f) //<-New line
                {
                    unityRigidbody.velocity += linearDelta;
                    unityRigidbody.angularVelocity += angularDelta;
                }
            }
        }

That will allow rigidbodies to go to sleep.

kind regards,
Reply


Messages In This Thread
RE: ObiRigidbody prevents Rigidbodies from sleeping - by josemendez - 13-04-2023, 02:20 PM