change to next scene in array

Godot Version

v4.2.1.stable.official [b09f793f5]


I have my game go from one scene(level) to another when the player hits a certain collider, so far so good.
now I want this to somewhat automatically select the correct next scene
my approach has been adding all scenes to an array via

preload(“res://levels/scene-1.tscn” preload(“res://levels/scene-2.tscn”

then I’ve been trying to get the current scene and look up it’s index in the array
add 1 and load that.

however i don’t think its possible to get the current scene as a packagedScene/preload
and I don’t know how/if I can add inactive scenes to an array

am i barking up the wrong tree with this approach or is there a sensible way of doing this?

I have resorted to defaulting to index 0 of my array for now,
adding 1 each time the function is called
not really what I was trying to do but it works as long as progression is forward only.
would still much appreciate help with this,
but this works for anyone trying to do something similar
( the “loadScene():” function is called by the Player )

extends Node2D

var levels: Array
var cur
var lvls: Dictionary

func _ready():
levels = [
preload(“res://levels/scene-1.tscn”), ]
cur = 0

func loadScene():
func loadNow():

this, why it’s impossible? you just need to save current scene’s index or even its resource path name and load it later?

add inactive scenes?
just add the index or scene resource path to an array when you switching to new one?