I have an airplane with Rigidbody and a Collider attached to it. The Rigidbody has Is Kinematic set to true because I use Transform to change its position and rotation.
I would like to test for a collision if airplane hits ground.
This is my code that’s a component of airplane:
void OnCollisionEnter(Collision collision)
{
Debug.Log(collision.gameObject.name);
if(collision.gameObject.name == "Terrain")
{
Instantiate(explosion, transform.position, transform.rotation);
Destroy(gameObject);
}
}
The Terrain (ground) has Is Trigger set to false and is set as Static.
When I test my code Debug.Log() logs “Terrain” but the “if” statement wont pass. If I try to collide with other GameObjects (instead of “Terrain” some other name) that have a Rigidbody and a Collider everything works ok and “if” statement passes.