Attention | Topic was automatically imported from the old Question2Answer platform. | |
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
Attention | Topic was automatically imported from the old Question2Answer platform. | |
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
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:
pass
else:
pass
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:
pass
else:
pass
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