RigidBody vs. Parent Behavior Change in 2022.x.x

I’m working on a flight sim project, and we use a “floating origin” system to move the world and all it’s contents closer to the origin to maintain floating-point precision.

I’ve noticed that rigid bodies don’t act exactly as they have in the past when their parent objects are moved. Some of our “moved” RBs are now snapping back to their world-space positions, particularly when set to Interpolate.

Can anybody chime in with knowledge of what may have changed here. This is subtle and unlikely to exhibit problems for most applications, but it’s killing us.

Are you using AddForceAtPosition. I am encountering an issue caused by floating origin messing up an applied forces position. It will make your craft spin violently when you do a floating origin move.

CC @yant , @albert-jurkoit

Works fine if I use addforce or addtorque, but totally screws up if I use addforcetoposition.

found some code that computes torque from force and was able to adapt it to work with local coordinates to compute an addtorque force that works without floating origin breaking it.

public static class PhysicsUtility
    {
        public static void AddForceAtPositionLocal(this Rigidbody body, Vector3 force, Vector3 position,
            ForceMode forceMode = ForceMode.Force)
        {
            Quaternion rotation = body.transform.rotation;
            body.AddForce(rotation * force, forceMode);
            body.AddTorque(rotation * Vector3.Cross(position - body.centerOfMass, force), forceMode);
        }
    }
1 Like

Actually, it has nothing to do with adding forces, etc. That all works fine in our situation. The change in behavior with Unity versions is that previously if I moved the root node of the world, the vehicle moved correctly along with it. Now, when our floating origin moves the root of the world, the vehicle restores itself to it’s previous world position the next frame. If I turn off the rigid body, this doesn’t happen.

I feel like there is a change to how/when the rigid body feeds the position back to the transform.