So I’m beginning to code in C++ for my prototype and currently I do not know all the ways in which I’ll be using multi-threading in the final project. What I do know is that I want to place on a separate thread things that should run in the background that otherwise would slow down the main game thread. I have two major purposes for this particular worker thread, tracing and loops. With tracing this is simple enough. I had a prior question about having certain things perform a certain action in relation to another actor but the actor it interacts with would be based on its proximity to said actor. Link to said discussion here for context: Fill Variable Based on Proximity
Ultimately I did receive a solution I’m happy with but since the blueprint I built already has it set to where it won’t do anything if the connected actor variable is valid, and the person providing it said that it’s not exactly the most optimized solution, I’d like to know how to build a thread to perform a trace without locking up other threads. That’s one purpose, the other one is that my blueprint has a series of situations where for loops would be used and I’d like to be able to have the for loop play on a separate thread while the game plays so the loop interations can run unimpeded by other things in the game thread. I do have project files but at least according to the tutorial I followed, the setup still doesn’t seem to work with for loops in particular. So I’d like a solution that would allow traces to be performed in the background without crashing the program, and the same for either loop iterations being possible to run without playing in between frames or, if that’s not possible, a way to approximate a loop on the thread that will allow the individual iterations to run in the background without crashing the program.
Thank you for your responses.