#Need help. Respawning slime in same spot not working.
15 messages · Page 1 of 1 (latest)
Try putting a breakpoint inside the spawn_slime() function, step through it to see if the slime's position is being set how you expect.
Also, try opening the game and then switching the tree view to remote, so you can see the node tree of the running game. See if the slime is being properly added.
When I first run the code, I can see there's two slimes
Then the one inside Spawner node disappears but the other slime on the outter branch stays and does not update.
E 0:00:49:0687 Main.gd:14 @ _on_player_attack(): Index p_index = 0 is out of bounds ((int)data.children_cache.size() - data.internal_children_front_count_cache - data.internal_children_back_count_cache = 0).
<C++ Source> scene/main/node.cpp:1694 @ get_child()
<Stack Trace> Main.gd:14 @ _on_player_attack()
Player.gd:19 @ _on_attack_timer_timeout()
Huh. Okay, so, there's a slime that's a child of the Spawner scene. But you're also adding a slime as a sibling to the Spawner in the Spawner's _ready() function
So that's why there's two slimes
And the slime that's already there at the start doesn't have its death signal connected to the Spawner
So that would be why nothing happens when it dies
The Spawner spawns slimes as siblings to itself, but the attack function you have expects the slimes to be children of the Spawner.
Start by deleting the Slime that's inside the Spawner scene
And then you'll probably want to change the Spawner's code so that it adds the Slimes as children of itself, rather than children of its parent