Reputation: 5
I have a project where I have to create an endless runner game in unity. The problem I have is in the collision aspect of the game where the sphere and one of the objects collide I want the sphere to be destroyed. This is the code I have for it:
private void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == "lethal")
{
Destroy(gameObject);
}
}
I tagged the objects within the game as lethal
. The problem is even with this code the sphere, when colliding, is not destroyed rather its just an obstacle that stops the ball rather than destroying it.
Any help? not sure what i am doing wrong
Upvotes: 0
Views: 497
Reputation: 761
And if you really want to use physics, make a child object to your runner and that should trigger the collision instead of your runner. And give the tag to that child object
Upvotes: 1