#need help with enemy spawner

18 messages · Page 1 of 1 (latest)

undone sail
#

need help with enemy spawner

tidal kayak
#

your "hole" variable is null for the spawned enemy

#

if you're assigning the hole variable manually for the enemy you added on its own, then you can do the same for the enemy spawner and do "enemy.hole = hole" when instantiating the enemy

undone sail
#

I realized that the "hole" node is null, but I'm not sure why, or how to make it NOT null

strong chasm
#

on which node did you add the enemy with add_child?

#

is it on the same level as the enemy that you've added directly on scene?

#

that might be the problem since you've hardcoded the hole's node path on your enemy's script

brittle star
#

You should see a warning in the debugger window then where it says it can't find the node at that location

undone sail
#

Although I can spawn the enemies now. I'm still having another issue.

#

When the enemy touches the hole in the center, I'm using the queue_free() function to make it despawn. The issue is that i can't spawn multiple enemies at a time, and after the first one "dies" and the game tries to spawn in another, I get this error:

undone sail
#

found out I can't "add_child" after the instance has been freed, so is there a different way of doing that?

strong chasm
#

Setting visibility to false will also disable physics interaction for that node if I'm not mistaken

undone sail
#

after thinking about it, I don't think my problem is with making the enemies despawn

#

I think I just need a way to make multiple of the same instance at the same time