+1 vote

how can I create instances of Scenes or for example the TestCube when using a function that is run by another thread?
When I try to create an instance from a threaded function, the thread never finishes and stays active forever.

Here is a quick example (commenting out the line var testcube = TestCube.new() makes the script run without problems)

extends Node

var thread1 = Thread.new()
var thread2 = Thread.new() 

 func _ready():
    print("starting thread")
    thread1.start(self, "threadedFunction1")
    thread2.start(self, "threadedFunction2")
    print("waiting to finish")

func threadedFunction1(var data):
    print("load testcube")
    var testcube = TestCube.new()

func threadedFunction2(var data):
    print("doing something else")

func done1():
    print("thread1 done")

func done2():
    print("thread2 done")


in Engine by (13 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.