Godot 4: Build a 2D Action body_entered problem!

Hello, i have started to learn Godot with the course Godot 4: Build a 2D Action-Adventure Game. At the 3.6 about changing scene, i get a problem, the _on_body_entered start when i start the scene.
here is the code

func _on_body_entered(body: Node2D) -> void:
	print("The player entered me!")
	get_tree().change_scene_to_file("res://Scenes/DungeonScene/dungeon_scene.tscn")


func _on_body_exited(body: Node2D) -> void:
	print("The body has exited me!")
	pass # Replace with function body.

i’m with Godot 4.3
Capture d’écran 2025-02-23 221238
Here is the capture of my Area2D and my player. I don’t know why i see The player entered me! when i play the scene.

Any advice where i must look how to debug that?

Thanks for your help

Rewatch lecture 3.6 (Changing Scenes) from about 6:35 to the end, where Ahmed shows the problem that arises before you add verification to _on_body_entered().

Do you see how the top of your entrance is clipping into the trees? Those trees have a CollisionShape, just like the cave obstacle. Complete the lecture and you should find that this problem gets cleared up =)

1 Like

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

Privacy & Terms