Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  I want to put an object to sleep
#1
I have an object that I put to sleep using a script. Collider, Rigidbody, Obi Collider, Obi RigidBody have been added.
When I place the Obi Emitter in a remote location (eg 10000m) and play it, the object's Sleep is instantly released.
Sleep is enabled by removing the object's Obi Collider, Obi RigidBody, or by removing the Obi Emitter.

Isn't the object to which Obi Collider and Obi RigidBody added become Sleep?
Reply
#2
(20-08-2021, 06:42 AM)moyashiking Wrote: I have an object that I put to sleep using a script. Collider, Rigidbody, Obi Collider, Obi RigidBody have been added.
When I place the Obi Emitter in a remote location (eg 10000m) and play it, the object's Sleep is instantly released.
Sleep is enabled by removing the object's Obi Collider, Obi RigidBody, or by removing the Obi Emitter.

Isn't the object to which Obi Collider and Obi RigidBody added become Sleep?

Hi,

This is a known bug in Unity: setting the velocity of an object will keep it awake, even if the change in velocity is zero. Internally, Obi sets the velocity of all objects involved in the simulation, preventing them from sleeping.

A hacky workaround to this is to modify the UpdateVelocities method in ObiRigidbody.cs, to check if the velocity change is very small and then avoid modifying it:

Quote: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 (linearDelta.magnitude > 0.0001)
                    unityRigidbody.velocity += linearDelta;
              if (angularDelta.magnitude > 0.0001)
                    unityRigidbody.angularVelocity += angularDelta;
            }
        }
Reply
#3
(24-08-2021, 04:44 PM)josemendez Wrote: Hi,

This is a known bug in Unity: setting the velocity of an object will keep it awake, even if the change in velocity is zero. Internally, Obi sets the velocity of all objects involved in the simulation, preventing them from sleeping.

A hacky workaround to this is to modify the UpdateVelocities method in ObiRigidbody.cs, to check if the velocity change is very small and then avoid modifying it:
Was it a Unity bug!
I will refer to your advice.
Thank you very much.
Reply