![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | spoicat |
Backstory: I’ve made a scene named Level
as a template for all of the levels of my game and used “New inherited scene” feature to inherit the levels and edit the stuff I need to. To tell the level which scene is next, I used export variable in the main level script and manually selected the scenes which are next (So I won’t have to create an inherited script too just for that).
Code:
extends Node2D export var next_level : PackedScene onready var player = get_node("Actors/Player") func _ready(): $LevelEnder.connect("body_entered", self, "end_level") func end_level(body): if body == player: if next_level: get_tree().change_scene_to(next_level) else: print_debug("No next level defined!") func restart_level(): get_tree().reload_current_scene()
The actual problem: There you see I’m using get_tree().change_scene_to(next_level)
in the function end_level
but it restarts the scene instead. I’ve double checked If I’ve selected the wrong level but I haven’t.