On destroy when collider is fast enough?

Hey there, i’m searchin for a solution for the following:

I want to destroy a GameObject on collision, but only when the other collider is fast enough.

For example if a car with low speed hits a tree, then the tree should not break. When the car is fast enough the tree should break/destroy.

How can i quantify the speed of a collider?

Hope you guys know what i mean.

Code could look like this:

public float speed; // Question is, how to count this float?
 
 void OnCollisionEnter(Collision collision){
      if (collision.collider.tag = "Car" && speed >= 10)
     {
      destroy(gameobject);
      } else {
      debug.log("Not fast enough");
      }
 }

Sorry for bad english.

Greets

I did’nt Test it but you can Create 2 Float variables that stands for both speeds you need. For example

public float FastSpeed = 50;
public float SlowSpeed = 20;

And I’n your Collision Try something Like this.

Void OnCollisionEnter(Collision obj)
{
   if ( YourCarSpeed >= 50)
       {
            // Do whatever u want
           Destroy(this.gameobject);
        }

   else if ( SlowSpeed <= 20)
       {
            // Do whatever u want
           Destroy(this.gameobject);
        }
}

thank you, but that’s what i know and what my code from above means, what i want to know is, how can i count the speed? is there any method or something like this?

Edit: Found this:

rigidbody.velocity.magnitude