Godot Version
4.2.2
Question
I have the signal working, everything works, but the _on_body_entered() doesn't get called.
4.2.2
I have the signal working, everything works, but the _on_body_entered() doesn't get called.
Please can you provide more details. Its not enough to solve or catch the problem.
The code looks like this, the signal works. but the 1st print() wont be called, nor will anything else in there. I can tell it is ready by another print debug.
func _on_body_entered(_body):
print(“Body entered”)
get_tree().change_scene(“res://Levels/Tutorial1.tscn”)
How did you connect the signal?
Using the Node tab, connecting _body_entered() to on_body_entered() in the same node as connecting from.
What is the body
that is supposed to be entering?
A CharacterBody2D named “Player”
It could be an error here, however earlier you wrote _on_body_entered() but later you wrote on_body_entered(). Is this an error in the code like this as well?
Also if you connected it in the inspecter there should be a green symbol to the left of the func in your script, do you see this? If not it isn’t being properly connected.
Does the player have a collisionshape?
Make sure theres an arrow pointing to a square near to the line number.
Is the script in autoload?
I checked, there is no such error and the signal is active.
Yes, the player has a CollisonShape2D. Yes, the green signal icon is there. No, the script is not in autoload because I am using it for one specific interaction.
Check that your area2d has monitoring=true and that its collision mask has the collision layer the player belongs to.
It worked! For some reason my Player node is in layer 2 so i just made it detect layer 2!