I’m new to Godot, and I have followed several videos on how to do fairly basic tasks. Right now, I have an Area2D node with a CollisionShape2D and a Sprite2D as children nodes.
Earlier today, I gave the Area2D the _on_body_entered function through the Node tab on the right menu and entered this line.
func _on_body_entered(body):
print(“Yay”)
When my Characted2D entered the collision, it successfully displayed Yay as it should. I saved everything, touching nothing else, and closed my computer. Now, after opening Godot a few hours later, it does absolutely nothing. I changed nothing, not the collision layers, the monitoring, nothing.
I erased the entire node, remade it, rewriting the line of code again, and it still doesn’t work. I verified my collision layers, the character being on layer 2 and the Area2D being on mask 2 (even switched them around), the Area2D is monitoring and monitorable, and even tried in a fresh project.
I have read through the documentation for Area2D, CollisionShape2D and _on_body_entered at least twice, look at forums with similar questions than me for 3 hours now, and nothing helped yet.
Thanks in advance to anyone that can help me.
Hi!
Seems strange, but should not be too hard to fix, I hope.
Could you share some screenshot? Your node, the _on_body_entered signal in the editor, the code, etc., so that we have more context?
Have you checked if the signal is being connected correctly? I believe that this is the step that’s forgotten the most, but I can’t be sure.
1 Like
Thank you so much for your answer!
Here are some screenshot.
Godot seems to not want me to add more than 1 screenshots since I’m a new user, but basically, the second screenshot was showing the Node tab on the right and that the function was connected, and the third was the Character2D being on layer 2.
I’m expecting the problem to be either
1.Something happened when I updated my PC after saving (unlikely tbh)
2.I’m missing something so simple that I’m overlooking it.
As far as I can tell, the signal seems connected (the green icon left of the code), but maybe I’m misunderstanding what it really means and forgot to connect it somewhere else. Anyway, thanks again, I appreciate any info you can provide.
Looks like the signal is connected indeed.
Maybe you could try by removing all layers on all objects, to see if that would be the cause?
1 Like
I did just that, turns out, I was using the layers completely wrong. All I needed was for the potion to have the same mask as the player’s layer, which I could have sworn I tried multiple times by now. I think I had them in reverse.
You have a been a great help, thank you so much.
1 Like