Hi, I want to make when two same type of object collide together, it will destroy both object and spawn one object.
For example, when two Cube collide, both Cube will be destroy, then a BigCube will spawn at one of Cube position.
For now my code is like
OnCollisionEnter(Collider other){
if(other.gameObject.name == gameObject.name){
Destroy(other.gameObject);
Instantiate(BigCube, transform.position, transform.rotation);
Destroy(gameObject);
}
}
But when I run the game, if two cube collide, it will instantiate two BigCube. What should I do to prevent two BigCube instantiate to the game?