Instancing objects in thread.

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

Hello! I can’t instance scene in thread because thread doesn’t return instance and i can’t add scene as node child.

What can I do to instance scene in thread?

func _process(_delta)
	if get_node_or_null('Props') == null:
		var thread = Thread.new()
		var instance = props.instance()
		add_child(instance)
		for i in $Props/Scatter3D.get_children():
			if i.is_in_group('prop'):
				if i.get('data'):
					if props_data.has(get_path_to(i)):
						i.data = props_data[get_path_to(i)]

You are only creating a thread not using it from the code you posted.

https://docs.godotengine.org/en/stable/tutorials/threads/using_multiple_threads.html

timothybrentwood | 2021-11-28 13:22