Split rigidbody into pieces

hey my game development fellows :smile:

i got stuck in a problem with the physics engine by unity. there is a barrel wich should break into pieces if it collides with another object faster than a specified velocity. now the problem is: how to know the torque of these pieces?

say for example:
-the barrels rigidbody rotates with a torque of (0.7,0.7,0)
-than it collides
-the velocity of the pieces can easily get by using “GetPointVelocity()”
-now destroy the barrel itself, spawn the pieces and apply the velocity .

it is important that it is physically correct.

hope anyone has some ideas /suggestions.

cheerio sumaccamus

You men junks body parts ? You can try add physic on fly.

function AddPhysics()
{
    if (colliding)
    {
        if (physicObj.gameObject != null)
        {
            physicObj.gameObject.AddComponent(DestroyTimeScript);
            physicObj.transform.DetachChildren();
            physicObj.transform.parent = null;       
                   
            physicObj.gameObject.AddComponent(Rigidbody).interpolation = RigidbodyInterpolation.Interpolate;       
            physicObj.gameObject.AddComponent(MeshCollider).convex = true;
        }
    }   
}

Hope help your needs.

i don’t get the point. :face_with_spiral_eyes:
not sure how this helps to find the correct torque.

Vector3 localangularvelocity = transform.InverseTransformDirection(rigidbody.angularVelocity);