05-02-2021, 08:45 AM
(This post was last modified: 05-02-2021, 09:21 AM by josemendez.)
(05-02-2021, 12:53 AM)madzilla Wrote: Appreciate the quick reply! I'm new to all of this and still trying to find my way around...
A few more details on my setup. The rigidbody in motion is not attached to the rope but does contain a Obi Collider and an Obi Rigidbody so it can possibly collide with the rope. Collision appears to be working just fine. There is only one rope and one solver in the scene. Solver settings are all default.
My Obi Fixed Updater is set to Subset Unity Physics = unchecked and Substeps = 4.
It's a pretty simple setup right now. Just a rigidbody that has a single force applied to it once in FixedUpdate.
Hi there,
Dug a bit deeper and discovered a potential a bug in Unity:
Obi does not mess with rigidbodies' sleeping state in any way. All it does is:
- Grabs rigidbody velocities at the start of a step.
- Modifies these velocities as a result of collisions, attachments, etc.
- Writes back the modified velocities at the end of a step.
If the velocity is zero (or near zero) at the start of the step and no contacts or other interactions take place, it will remain zero at the end of the step. Thing is,
setting the velocity of a rigidbody to *any* value wakes it up, even if this value is below the velocity sleeping threshold. Since the updater sets the ObiRigidbody velocity regardless of it having changed, it keeps it ever awake. Using Unity's physics debugger window makes this easy to see.
So, doing this guarantees the rigidbody will never go to sleep:
Code:
unityRigidbody.velocity = Vector3.zero;
This behavior doesn't make any sense whatsoever, specially considering it's not how PhysX (Unity's underlying physics engine) works by default: it won't wake up a rigidbody if you set its velocity to zero.
The workaround is fortunately simple, if not very elegant: force Obi to check if the velocity delta is above a threshold, if it isn't don't apply it. Replace lines 62 and 63 in ObiRigidbody.cs:
Code:
unityRigidbody.velocity += linearDelta;
unityRigidbody.angularVelocity += angularDelta;
with this:
Code:
if (Vector3.SqrMagnitude(linearDelta - Vector3.zero) > 0.000001f)
unityRigidbody.velocity += linearDelta;
if (Vector3.SqrMagnitude(angularDelta - Vector3.zero) > 0.000001f)
unityRigidbody.angularVelocity += angularDelta;
Will investigate this with the Unity guys, as it's quite counterintuitive. Here's the thread: https://forum.unity.com/threads/rigidbod...o.1052369/