Hey, I’ve got a small sample of code working in my Player based buildings project.
It records a series of bounds that change in a given update and runs them all at once using:
It was performing really slowly (causing seconds of delay between frames). I’ve messed with tile size and things to make it faster. I then worked on combining bounds that overlap to limit the number of update calls - this actually worked fairly well, but still causes the main thread to block?
I was wondering if there was a way to run these updates on a thread/in the background?
Assuming you have enabled multithreading (A* Inspector -> Settings) the main part of the work should be done on a separate thread. What cannot be done in a separate thread is primarily to find all the objects that are going to be involved in the update. This can be very slow if you have ‘Rasterize Meshes’ enabled as there is no fast way to find those. I would recommend using ‘Rasterize Colliders’ instead. Also make sure you are using a relatively recent version as there have recently been improvements to the performance of recast graph updates.
Perfect. I totally forgot I disabled threads. Instantly worked as I was already using colliders. Great work.