Im doing a 3D rpg style game and I want the player to enter a room switching between scenes.
I have two scenes, the outdoors and the room.
For switch, there is a scene with a simple 3dArea and a "@export var scenetochange: PackedScene" where I put the scene where the player goes from the Inspector and is a copy of that in the outdoors and the room.
The player can go one way, but when tries to go again the var scenetochange is not set.
Im doing something wrong with the change_ scene or maybe i am wrong doing the reusable scene?
The code for the area is this:
extends Area3D
@export var scenetochange: PackedScene
@export var active: bool = true
func _on_body_entered(body):
print("trigerChangeScene")
print(scenetochange.resource_path)
if body.is_in_group("player"):
if scenetochange && active:
get_tree().change_scene_to_packed(scenetochange)