I’m following along with a tutorial (https://youtu.be/FNEAJsry5sA?si=PKszaXqG-kT2oUK9&t=4964) because I’m new to Godot and have come to a roadblock. Mine and his code look almost alike (i skipped some parts for they are less important for the time being) and in his code, when the character touches the end, he prints win, while mine prints once as the game loads and then not after any ideas why?
My code:
My scene tree:
If your tilemap has collision it is also a “body”. on load, the tilemap enters the area. The tutorial assumes only the player can enter the area, you could do a number of this to fix this.
I would recommend adding an if statement to ensure the game only moves to the next scene if the player enters the area. This could be done by comparing the colliding body’s name.
func _on_end_body_entered(body: Node2D) -> void:
if body.name == "Player":
print("win")
After some testing, now when my game is ran, it knows that it has touched something but can’t tell if it’s a player. When moved off the ground, it prints nothing, but when touching the ground, it prints: “I touched something”.
I’ve been testing two things, one scenario where the end’s hitbox is touching the ground, and another where it is.
In scenario one, it prints this out.
Whereas in scenario 2 it prints nothing.
I have tested multiple movement methods to verify that I have touched the two hitboxes together, such as jumping into the flag.
I have also tried changing the if statement to check for “collision”, and changing the argument to “body: Node2D”