Jambutters Posted May 19, 2016 Share Posted May 19, 2016 How would I go about doing that? Applying a mass pathfinding to lets say over 800-1300 mobs, without killing the client or server sides ram and cpu usage. Also does rendering that many mobs on the screen kill the clients cpu/ram? Most likely will be using pixijs for rendering. Quote Link to comment Share on other sites More sharing options...
mattstyles Posted May 20, 2016 Share Posted May 20, 2016 Pixi should be able to handle ~1000 sprites with little effort, depends on size and texture swapping but it'll likely be fine. Try to use a texture atlas where possible to reduce expensive calls. For pathfinding, cheat as much as possible, for example, if units are a long way off and not visible by the player then there is (maybe) no need to plot their course exactly, you could just make an approximation of how long it will take them to move from A to B and just move them, no need for a path. Similarly, can you group the entities in such a way that they share a path? If your path generates a series of points then you could introduce some jitter or variation to how each entity follows those points so that each individual path might seem slightly different but the expensive path operation is performed only once. Use the cheapest path finding algorithm you can and plot short paths, possibly using an even cheaper method to guess intermediate points for longer paths and then stagger plotting those smaller paths. Limit your AI to spending only so much time processing path finding, JS is single-threaded and you probably don't need to be calling out to web workers for short algorithms like path finding, you don't want your path finding hogging all the CPU when it is under load, try to spread the load out. Note that this is rarely trivial, test if you need to do this. For lower powered devices/machines can you reduce the number of entities in the world? Or segment the world more drastically so that you effectively drop the entity number per chunk. Test test test. You might be surprised at how fast JS can be. Never optimise before you have performance tests that firstly inform whether you even need to optimise and secondly tell you how your optimisation work is actually going. Quote Link to comment Share on other sites More sharing options...
Jambutters Posted May 21, 2016 Author Share Posted May 21, 2016 On 5/20/2016 at 10:51 PM, mattstyles said: Similarly, can you group the entities in such a way that they share a path? They all should generally share the same path to path to the players(due to them being zombies lol, they should be a bit dumb). Alright thanks for answering my question matt. Hopefully it doesn't kill the server side of things, along with bandwidth when I put this into action lol. mattstyles 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.