Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Syntax |
Hello, my question is, I have a object (Node 2d where exists Area 2D and my code is in Area 2D because of this code:
extends Area2D
export(String, FILE, “*.tscn, *.scn”) var target_scene
func _ready():
pass
func _input(event):
if Global.unlocker_portal == true:
if event.is_action_pressed(“ui_accept”):
if !target_scene: #is null
print(“no scene in this door”)
return
if get_overlapping_bodies().size() > 0:
next_level()
if event.is_action_pressed(“ui_accept”):
if get_overlapping_bodies().size() > 0:
print(“Ohhh”)
return
if Global.unlocker_portal == false:
if event.is_action_pressed(“ui_accept”):
if get_overlapping_bodies().size() > 0:
print(“A chave não foi ligada”)
return
func next_level():
var ERR = get_tree().change_scene(target_scene)
Global.unlocker_portal = false
if ERR != OK:
print("Something failed in door scene")
Global.portal_name = name
And i need to connect a target scene because if it is not connected my player cant after leave the door spawn near the door.
I will be grateful if you can help me.
Thanks.