hey, im making an open world game, and i need to get the force applied on gameobjects (eg: cars), so that the mesh (eg: part of the car) gets deformed at different amounts, when another object hits it. (btw: im using custom meshes, which will become visible when necessary)
unity obviously calculates force applied on rigidbodys (rigidbodies or whatever), so they get affected when another rigidbody pushes/hits it. can i somehow get that value (the force)?
Using OnCollisionEnter you can access a Collision object. The Collision object has all sorts of information about the collision in question, including the relative velocity.
void OnCollisionEnter(Collision collision)
{
Vector3 velocity = collision.relativeVelocity;
}
Other useful data that may help your use case are:
Vector3 impactForce = collision.impactForceSum;
ContactPoint[] contacts = collision.contacts;
You could check the force in OnCollision with Unity - Scripting API: Rigidbody.velocity