Hi,
I have this strange problem with collision detection. The “OnCollisionEnter” works fine if it’s attached to a gameobject which I put into the Scene manually; however if I want to instantiate the same gameobject’s prefab (example: by pressing a button) the gameobject prefab is instantiated, but the collision doesn’t work anymore.
WTH? Help please p.s. I have tryed the OnCollisionStay, but it didnt help :(.
The code (enemy):
var BoomExplosion : GameObject;
function OnCollisionEnter (TriggerEnter : Collision)
{
if(TriggerEnter.gameObject.name == “BoomExplosion(Clone)” || TriggerEnter.gameObject.name == “BoomExplosion”)
{
Instantiate(SpawnExplosion, gameObject.transform.position, gameObject.transform.rotation);
Destroy(gameObject);
}
}