Question by
unity_McDQyp7qhCTdXw · Aug 03, 2020 at 07:45 PM ·
prefabscollider2dprefab-instance
OnTriggerEvent Instatiate one prefab
0
I am trying to spawn a boss via a 2D collision trigger
The trigger seems to be spawning twice though before the gameObject is destroyed. essentially it spawns some particles, then the boss, if I destroy the gameObject first then it won't spawn at all as it will have no spawn point to link to.
Can anyone help me amend the code?
Currently it is as follows
Thanks
void OnTriggerEnter2D(Collider2D collider)
{
Instantiate(BossParticles, transform.position, Quaternion.identity);
Instantiate(Prefab, transform.position, Quaternion.identity);
Destroy(gameObject);
}
Comment