Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Syntax |
Hello, some one can help me how to put a var target scene in node 2d and area 2d in godot. Because only my area 2d asks me a target scene and if i put target scene is node 2d that just is apart.![enter image description here][1]
Here is a script of Area 2d
extends Area2D
export(String, FILE, “*.tscn, *.scn”) var target_scene
func _ready():
pass
func _input(event):
if Global.portal_first_quest == 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()
Global.portal_first_quest = false
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
Global.portal_first_quest = false
if ERR != OK:
print("Something failed in door scene")
Global.portal_name = name