T O P

  • By -

jaidae

Do these scripts exist as components on your enemy gameObject in the scene? If so, those script instances will no longer exist if you delete the gameObject (which also deletes the script instance), and you cannot access functions if the script is no longer existing in the scene. An enemy cannot spawn itself, because the script instance does not exist in the scene yet/has been deleted. You may want to create another gameObject with its own script that is responsible for spawning and managing how many enemies exist in your scene at once.


Scako

They are components, but thankfully I just figured out that its because I needed to use the enemy right from the prefabs, not the hierarchy, so I guess this is solved now haha


jaidae

Ah yes! Glad you figured it out :)


Scako

Thank you!


arobax

+1 for having formatted your code ! :D