Context: I’ve just started moving from blueprints into C++ because I need to multithread my CPU-heavy project. The first thing I’d like to multithread is my A* pathfinding. I’ve converted my blueprints into c++. My problem is that the game crashes during standalone bootup so I don’t even know how to test it with UELog or screen prints.
I’ve submitted my error logs and code to ChatGPT and it suggests potential memory handling issues or that I’m not properly killing the FRunnable thread. I’ve been spending days messing around with ChatGPT’s suggestions. I feel like ive google everything, but there isnt a lot of info on FRunnable. Was hoping a pro could look over this to see if I have pointer issues or an infinite loop. It works perfectly in blueprints and converting it to C++ seemed pretty straight forward.
The other insanely annoying thing is that it compiles fine and then when i run it it crashes and breaks all of my C++ structs and various pins & functions in the C++ actor class in blueprints. Then i have to rebuild literally everything just to test it again.
Did you save the blueprint? Losing changes in the blueprint should only happen if you did not save it before trying it.
Start the UE-Editor from Visual Studio with F5, then do as normal until the game crashes, use the callstack, scroll through until you find lines in YOUR code and check these lines for your error.
I’m feeling like I’m never gonna get past this uggh. Any suggestions? Im trying to put UELOG reports at every step of the way but it seems like its not even getting into the class before it crashes.
I’m surprised you even got yours to compile. The functions wont take pure enum arrays.
Next time please post the accompanying enums and structs.
People will help you, but value their time.
Not everyone will have the patience to recreate missing files based on sparse data.
Here is example data. The map creates a 3x3 grid all tiles are valid EXCEPT the middle one (marked obstacle). The pathfinding starts at 0,0 and should end at 2,2 avoiding the middle tile 1,1.
You error was in GetValidTileNeighbors, you forgot to check if the passed in parameter Data is a null pointer. This would cause the engine to crash once you tried to access it and if it was invalid
I added in a check. Best to debug the algorithm and see if the proper data is being passed on
Run your ide with debugging enabled and put in break points into your c++ code. Once a condition is met and the debugger pauses you can then hover over variables near the debug point to see variable values and step over the code following it’s execution.
You probably still need to add a callback to the thread to let unreal know that the calculations are done so you can access the path
It boots up! Woohoo. It is definitely not returning the right information though. It’s returning an empty queue item, but i can work through this now. You’re a life saver!!! I was feeling defeated. So thank you.
Also, you helped me get sorted through the workflow now that I’m working in Visual Studio. I think I’m now on the right path.
No. It’s just that when you use threads they calculate at their own pace. You need to add in a delegate that you can call once the calculations are done to let the engine know that the work is finished => here are the presented path items…
No need for constant checking. It’s a waste of resources and not how threads are meant to work.