I have an Area2d with a CollisionShape on the right edge of my screen and I want to switch to another scene when my character enters the shape - but right now the player just leaves the screen forever.
I've got them both in the same Z Index but how to I get this to transition (I'm making a basic adventure game) to this other scene?
The script on my Area2d looks like this
extends Area2D
#Called when the Area2D enters another area
func _on_Area2D_body_entered(body: Node) -> void:
if body is CharacterBody2D:
# Load a new scene when the player character enters the trigger zone
load_new_scene()
func load_new_scene() -> void:
# Replace "res://Scenes/room1.tscn" with the actual path to your new scene
var new_scene = preload("res://Scenes/room1.tscn")
get_tree().change_scene(new_scene)