Hi, I am building a game in 2D (or 2.5D if you want) and it only consists of one screen where the player (a sphere) can move around, and other spheres are spawned and moving from outside the screen against the middle. these other spheres (called enemies at the moment, but aren't actually enemies) are supposed to destroy themselves ehwn colliding with other enemies.
My problem is that I can't get them to know when colliding with an other enemy. The nearest I have come in many attempts is this, which is written in the enemy spawner:
Which will make it so that it "collides" with it self and selfdestruct on spawn.
I have also tried to make a method in the enemy script that kills( Destroy(gameObject) ) it, which was called from the enemy spawner script, but then unity said I couldn't destroy in risk of data loss, which means it thought I wanted to destroy the prefab, not the clone. This is weird as I have stated the same thing in update if the clone is too far from the 0.0 coordinates and there it works great.
Well, thankful for help,
EDIT: I forgot to say (except in the title) that I use C# with monodevelopment in visual studio.
Why not put a script on each enemy that uses OnCollisionEnter and test for what the object has collided with? About the OnCollisionEnter:
So it should not "collide" with itself.
The script above would delete the enemy when it collides with another enemy if it is placed in a script attached to the enemies.
Hope this helps