How to make process false if a scene is instanced

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Newby

how to make an if statement like this

if scene is instanced:
	do something
elif scene is not instanced:
 	do something else
:bust_in_silhouette: Reply From: coffeeDragon

An instanced scene will give you a result. Save that into a variable and if that is null it’s not instanced.

var scene =load("res://my_scene.tscn")
var instance  = null
instance = scene.instance()
if instance != null:

Or you could attach a script to your top node and add it to a group each time it’s instanced.

_size = len(get_tree().get_nodes_in_group("scenesToCheck"))
if _size != 0:

As far as I know there is no inbuilt way to keep track of if a scene got instanced.

Ohh never thought of that thx

Newby | 2018-07-25 10:20