- Edited
Hi there,
I was able to make code which switches scenes when a KinematicBody enters an Area node. But I also need a line of code that teleports the player when he steps into a different area and it changes the scene but teleports the player to a new spawnpoint.
So something like this:
Player Steps In Scene Changer 1 > Outcome 1 > Location X = 20, Y = 12, Z = 30 Player Steps In Scene Changer 2 > Outcome 2 > Location X = 40, Y= 12, Z = 5 etc.
I do think the outcomes need be scene connected or something like that but I am not sure on that. for example:
Exits HouseScene1 > Outcome WorldScene2 Enters WorldScene4 > Outcome LevelScene1
this is the code that changes the scene when body has entered the area:
extends Area
var _is_player_in_Area = false
export (String) var player_node_name = "Player"
signal on_player_entered
var _start_new_scene = false
func _ready():
connect("body_entered",self,"_on_Scene_Load")
connect("on_player_entered",self,"_Print_Load");
func _process(delta):
if _is_player_in_Area == true:
emit_signal("on_player_entered")
_start_new_scene = true
get_tree().change_scene("res://Scenes/Scenes 3D/Title Screen/Title/MENU.tscn")
func _on_Scene_Load(other):
if other.name == player_node_name:
_is_player_in_Area = true
func _Print_Load():
print ("Load Scene!");
Thanks for the help :P