The For Loop

Hello, I’m having trouble with the FOR loop section. I followed along, but as soon as I disconnect the nodes, it stops resetting my player when touching the traps in the game. It’s not recognizing the signal in the for loop.


Hm. If the signal worked fine with manual connection, it couldn’t be anything to do with that. I’m also assuming the array code itself (at the beginning of the video) works as Kaan demonstrates that pretty heavily.

At the bottom of your window, I do see there are 4 Debugger messages with some of them being errors (as “Debugger” is in red), vs. Kaan’s 2 warnings; there’s a good chance that will shed some light on this. Could you post a screenshot of those?

Ahh, this makes sense. It’s worth clarifying that not all syntax/build errors will cause a Godot project to break; sometimes, Godot will fail silently, and that’s when looking at the debugger output becomes even more important than usual.

These errors are saying that they can’t find the touched_player signal on your trap objects’ Sprite2D node and Area2D nodes respectively. Of course they can’t, because those nodes are not what your trap script is attached to, and this signal exists only in the script.

Almost certainly this has happened because [the Sprite2D and Area2D respectively] were added to the Traps group. Instead, what should be in the Traps group is the root node of each object scene, so that this is the node looked at when iterating through the array. Try this and see if that fixes it =)

1 Like

forgive my ignorance, but how did sprite2d and area2d get added to traps group? and how do I fix that? I can’t seem to figure it out myself.

nevermind I fixed it

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms