Multi threading question, about dictionary

Godot Version

4.3

Question

`
hello, i’ve been working on a godot project for a while, somebody told me to make first some pong to learn godot, so i kinda went my way, clicked on keyboard until i unterstood what i am looking at

with help of ai, now i grasp array, string, dictionary, creating functions, calling functions, consts classes, now i understand more than just if and while loops from my arduino era, i now know for, match, and even that !=, some raycasting a little, and instead of pong, i made menu and keyboard that you can click

now i wanted to have fun with multi threads, but now i see where the issues are, and what i will need to do next, like appending data to something, and in process_delta check, if something there is like, to be put on the scene, and use main thread, instead of calling deferred, and after all the data is being added to tree, processed, we can start sending it to different scripts, better than whatever i do now with try_get_node, await stuff, as i see thousands of errors sometimes, and it can even crash funnily

as i already made that dictionary, where i append nodes into it, and send to different script, and in multi threads, i move these things around, and it works, i guess only adding nodes, moving them on scene tree, and freeing them is needed to be done on multi threads? i dunno

so my questions are, what is best way to add nodes to scene

			turn_number_process += 1
			if list_of_sets_to_create.size() > 0:
				if the_menace_checker == 0:
					the_menace_checker = 1
#					print("here we run thingy")
					create_new_task("process_stages", "from_delta_we_run")

now i just check, if some array is in bigger size than 0, and run an task that has while loop, that does steps to create all nodes, i am thinking of doing it in similar way, for placing nodes, freeing them, as call_deferred, for get_node, wasnt as easy for me, didnt really work, i dont like it, sometimes it even break stuff for me

and my another question is, what is in godot beside string, array, dictionary, that i should learn more in depth? i mostly have fun to make data move around and be organised

`

Nothing is required to be done on a separate thread, you can successfully build a whole game without ever touching the multi threading.

Just instantiating them and adding them to the scene with add_child().

I don’t really understand your usecase too much, but in general multi threading adds a lot of complexity to the code structure and unless you have performance issues, I wouldn’t go that route.
As you’re just tinkering around, it’s of course fine to learn and I encourage you to do that, but don’t be mistaken that you have to use multi threading for anything, because you don’t have to.

Try to understand tweening and interpolation - both are very useful tools that every gamedev uses basically daily.

well, when i made that keyboard, it frozen project for a split second, wanted to make it, so it won’t freeze, and it kinda did that, and multi threads add a level of satisfaction to figure out a way and have fun, for me, will figure out even better way to make that multi threading work without errors, thank you for writing

1 Like