Godot Version
4
Question
I want the scene to change when a Sprite2D mesh touches an Area2D mesh, how can I do it, is there anyone who can write sample code? :frowning_with_open_mouth:
4
I want the scene to change when a Sprite2D mesh touches an Area2D mesh, how can I do it, is there anyone who can write sample code? :frowning_with_open_mouth:
I would add a child or sibling node of type Area2D. Then, I can connect the first area2d signal with the player script. This would call a function which would check the body that entered the area2d was the child Area2D. Then, I could run any code. Maybe something similar to:
@onready var childArea = $"ChildArea2D"
func on_area_2d_body_entered(body) -> void:
if body == childArea:
do_something()
This code is untested and may not work. It also makes some assumptions about the scene tree.