How to make your own Factory Tick ish group
This might be valuable for anyone needing to make their own factory tick ish thing. Yes I know I am not following some C++ / Unreal style guides. I've been writing javascript for way to many years and your standards are ick to me lol.
You should look at using Factory Tick first. This is for special situations where what you want to do does not fall into the patterns of Factory Tick like moving items between inventories without using belts.
The Subsystem holds a list of everything we want to tick in this group and calls tick on them.
8 Replies
My Tickable Actor
My Tickable Interface
You can significant improve the performance if you tick a lot of actors in this way if you group them and limit the threats otherwise it overflows the queue.
thats some code from RP solar panel subsystem . it also comes closer to the FactoryTick
Ok, So since there is a max queue size we split our for loop into 8 groups and each group runs in a separate thread. makes sense. is it worth detecting how many cores the pc has and base our thread count on that?
I would at least have the decency of making it a named constant instead of a magic number :wonke:
But I don't think detecting core/thread count would do much since you'd have to account for the CPU being used for something else
This looks similar to what Digital Storage used to do for network ticks. I got rid of the 2D array to be able to use
UPROPERTY
and I got a substantial speedup (as I no longer had to rebuild the array every time)Yeah both is the same thing π In RP I write that thing idk 2/3 years ago? π in DS it was Basically a copy of this.
Of course is not perfect but itβs run π also donβt like some parts of this code ^^ since itβs not really clean π
Makes sense, just letting you know I refactored the copy in DS a while ago, so RP could benefit from it too
Never change a running system π but yeah maybe if we need to touch that part we can also refactor this π
updated with my final code, I do simpler math and accept that there will be a few nullPtrs that need skipped