SnpM / LockstepFramework

Framework for lockstep RTS, TD, and MOBA games.
MIT License
1.39k stars 348 forks source link

Room for Simulate() Optimizations? #156

Closed zzuumm closed 5 years ago

zzuumm commented 6 years ago

I notice that when there is a considerable number of agents in the scene (talking about >400 in my case) I start to get lag, and my machine is rather powerful compared to low-end or mobile devices. I'm wondering if this could be improved by not calling Simulate() on every FixedUpdate() but instead keep a "dirty" list of those who need to? This especially considers LSAgent instances and maybe even more specifically their abilitymanager simulation round.

Oh, how I tested this was just the ExampleScene (it's working now, thank you) and spawning default TestAgents as in tutorial part 2.

SnpM commented 6 years ago

The main issue is collision detection scaling quadratically. Partitioning and culling significantly reduce unnecessary collision checks but there's still a lot of iterating and collection accessing.

Fortunately, many of those calls can be optimized by the compiler. Try building the project and running it as a standalone. On my laptoaster, I can comfortably hit >1k objects with environment colliders while recording but definitely not 400 in the editor.

On Wed, Jul 11, 2018 at 9:23 AM, zzuumm notifications@github.com wrote:

I notice that when there is a considerable number of agents in the scene (talking about >400 in my case) I start to get lag, and my machine is rather powerful compared to low-end or mobile devices. I'm wondering if this could be improved by not calling Simulate() on every FixedUpdate() but instead keep a "dirty" list of those who need to run Simulate()? This considers especially LSAgent instances and maybe even more specifically their abilitymanager simulation round.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/SnpM/LockstepFramework/issues/156, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXqp8BTlN4QqucdiCTqbHhSyXhiPNdGks5uFlC3gaJpZM4VLtFt .