24-05-2022, 08:34 AM
(This post was last modified: 24-05-2022, 08:36 AM by josemendez.)
(23-05-2022, 09:43 PM)obiropequestion Wrote: Hi,
I'm running into an issue when using an obi rope and a rigidbody with an obi collider. As long as a rope is active in the same scene, the rigidbody's speed and velocity doesn't come to 0.
Here are two videos showing this in action: Imgur Video AlbumI've tried several things to troubleshoot:
- The first video shows the object with the obi rigidbody enabled and disable, as well as my settings for the rope and the solver in the video.
- The second video shows that when the object is not in contact with anything and the gravity is turned off, the speed and velocity decays to zero.
Is there something I'm missing here that would cause this to happen? Thank you for your help.
- Setting up a new scene, adding a cube with a rigidbody and a obi collider, then adding a new rope. This problem occurs again.
- Reading through the manual again and switching to using a distance field, changing chain constraints, etc. - no change.
- Adding collision filtering to the rope and rigidbody so that only the rigidbody interacts with the rope.
- Changing collision settings, constraints, and fixed update & late fixed update updaters - no change.
Edit: I'm using Unity 2020.3.11f1, standard render pipeline. I set up a new project with only ObiRope imported, added a single chain, and cube with a rigidbody + obi collider and ran into the same issue.
Hi Alex,
This is a known issue in Unity that we've reported several times in the past to no avail: when assigning zero velocity to a rigidbody (or the exact same velocity it currently has), it prevents the rigidbody from going to sleep and its velocity never actually reaches zero.
Additionally if a rigidbody is asleep, assigning zero velocity to it will wake it up.
Obi's simulation loop roughly looks like this:
- Read the rigidbodies' current velocity.
- Perform simulation using this velocity data, and modify it if needed (Obi actor collides with or is attached to a rigidbody)
- Write back the -perhaps modified- velocity for each rigidbody.
Even when the rigidbody velocity is zero or very close to zero and it isn't modified by Obi, just calling the velocity setter for the rigidbody will prevent velocity from reaching zero and the rigidbody won't go to sleep.
To workaround that, open up ObiRigidbody.cs file and modify the UpdateVelocities method (at the very bottom of the file) to look like this:
Code:
public override void UpdateVelocities(Vector3 linearDelta, Vector3 angularDelta)
{
if (Application.isPlaying && !(unityRigidbody.isKinematic || kinematicForParticles))
{
if (Vector3.SqrMagnitude(linearDelta) > 0.00001f ||
Vector3.SqrMagnitude(angularDelta) > 0.00001f)
{
unityRigidbody.velocity += linearDelta;
unityRigidbody.angularVelocity += angularDelta;
}
}
}
This will skip writing velocities back if they're very small, which isn't ideal but will work around the issue.