Butab

  • Apr 2, 2024
  • Joined Mar 31, 2024
  • 0 best answers
  • DaveTheCoder Either call it using call_deferred, or place its contents in a separate function, and call that function using call_deferred.

    Tried, game launched and after few seconds Windows says it's not responding lol

    Thread_process is called with: load_thread.start(Callable(self, "_thread_process").bind(null)) at _ready() function

  • DaveTheCoder

    for c in objects.get_children():

    If what, objects is onready variable with $Objects value

  • DaveTheCoder

    Yes it's different, I meant Unable to iterate on object of type 'Nil'. error is looks pretty same, sorry for the confusion

    `func thread_process(userdata):
    while(true):
    for c in objects.get_children():
    var cx = c.object_position.x
    var cz = c.object_position.y

    		var px = floor(player.position.x / Global.DIMENSION.x)
    		var pz = floor(player.position.z / Global.DIMENSION.z)
    		
    		var new_x = posmod(cx - px + load_radius/2, load_radius) + px - load_radius/2
    		var new_z = posmod(cz - pz + load_radius/2, load_radius) + pz - load_radius/2
    		
    		if (new_x != cx or new_z != cz):
    			c.set_object_position(Vector2(int(new_x), int(new_z)))
    			c.generate()
    			c.update()`
  • Hello, I have pretty similar error in Godot 4.2
    I used get_children(), but it gave me:
    MyScriptNameHere.gd:25 @ _thread_process(): Caller thread can't call this function in this node (/root/World/Chunks). Use call_deferred() or call_thread_group() instead. error
    Okay, maybe I should try both? I tried, and I have now:
    Unable to iterate on object of type 'Nil'. from call_deferred("get_children")
    and the same error from call_deferred_thread_group("get_children")...

    I don't know how to fix error
    pls help