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