Spawn of mobs causing slow down and lag. Possible solution
There is a very noticeable runtime impact when entity are spawned such as during the Sekhemas trial. Typically speaking from a game dev stand point, you need to optimize the entity pooling. Pre allocate more entity to the pools and double check you are not running bloated calls such as finding components. Component calls are a killer on runtime in Unity and can be avoided. I imagine you have something similar in PoE for your engine.
It looks like poor entity handling at spawn time or a heavy calculation that needs optimizing. You should be able to spawn around one hundred entity per frame without that kind of lag. Of course your frame time window is a big factor. Texture size and bandwidth aside, it should spawn a lot without that large runtime loss. There are some texture meshing techniques that can be used for entity of the same type spawning at the same time if that is the problem. Pacing the spawn between frames may be necessary due to memory and texture bandwidth limits clients will have versus the runtime time seen in test profiles. If you are using locks in the code process instead of a thread safe alternative, that may be why your runtime is suffering. I find many devs are unaware of the thread safe collection provided in C#. System.Collections.Concurrent. This should give a great example you could build into your engine. The access time is marginally slower but thread safe so only use it if the work load warrants it. You may also have a exponentials problem where distance and collision checks explode in numbers when entity counts get higher. Every entity is exponentially adding to the work load due to the iteration loops used to process them all. This can be improved by batch processing and pacing the work load between update frames. You may find some inspiration in the way Unity IJob system functions to avoid ram allocations and allow multithreaded work safety. Loving the game, ty for all your long hours and sleepless nights. Last bumped on Jan 13, 2025, 11:22:51 AM
|