The Code for the impact detection:
if(Mathf.Abs(Mathf.Abs(v.magnitude) - Mathf.Abs(rb.velocity.magnitude)) >= 3.5f)
{
Break();
}
v = rb.velocity;
->Works for Unity
Basically it just checks the difference between the velocity from the last frame against the current velocity and if the velocity diference is to great than the vase breaks.
I am not sure if there is a better method, but after looking for a pre-implemented "impact-strenght" or somthing like that in the "OnCollisionEnter()" or the "Rigidbody" itself and not finding anything. This did the trick : )
PS: the 3.5f is the mimimum impact-strenght required for the vase to break.
0 comments