Godot Version
4.2
Question
for c in chunks.get_children():
var cx = c.chunk_position.x
var cz = c.chunk_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.call_deferred_thread_group("set_chunk_position",Vector2(int(new_x), int(new_z)) )
c.call_deferred_thread_group("generate")
c.call_deferred_thread_group("update")
the children of chunks are StaticBody3D’s that are sub-threaded in thread group 0. There are no other nodes that are sub-threaded. This for-loop runs in the main thread in _process of the root node of the main scene. it doesn’t freeze the application when chunk’s children are not sub-threaded and are instead a part of the main thread. I truly have no idea as to why this happens. I have also found that any node I make a subthread, even after messing with the group order, does not actually run as a thread, even when they don’t freeze the application. as you can see I am using call_deferred_thread_group() to call functions on the sub-threaded nodes, and in the editor for the node I have also selected thread group > messages > process. To me it seems that this isn’t working as intended, but maybe I am doing something wrong?