cacotigon wrote:I mocked up a quick test with 400 objects all with collision detection enabled and it ran at a solid 60fps in Chrome. (YMMV especially on mobile devices)
MVG wrote:"collision check will be 200*200 which is 40000! This is because system will check the collision between monster with same team too."
I'm pretty sure 40,000 is correct, and what you want (the best you can get for this method).
Each of the 200 monsters on team A has to be checked against each of the 200 monsters on team B. That's 200^2.
If you wanted to check them against the same team too, that would be comparable to the "handshake problem" in mathematics.
Which would be 400*399/2 = 79,800 tests
You need another solution entirely if you want to optimize this. I recommend looking into cellular automata, and drawing on the power of the graphics card to accomplish this feat.
This isn't an easy problem to solve. Your best bet is reducing the number of monsters, if your game design will allow for it.
If you can tell us more about your game, and why such a large number is needed, we may be able to offer simpler solutions.
cacotigon wrote:First, check your average fps through the debugger, or with a Text object set every 0.5 seconds to "fps". I mocked up a quick test with 400 objects all with collision detection enabled and it ran at a solid 60fps in Chrome. (YMMV especially on mobile devices)
If the instances are being destroyed after the collision, you could take advantage of the performance gains of using "On Overlap" instead of "On Trigger" to see if that makes a difference.
More information on the differences between "On Overlap" and "On Collision" available here:
Overlap vs Collision
Given a total of 400 monsters, I'm assuming that your layout size is much bigger than your window size. If that is true and performance is still unacceptable even with the built-in use of collision cells, you can experiment with two different families.
There are disadvantages to using "On overlap" but if you're destroying the instances on contact, then it might not matter for you. Overlap may return multiple instances overlapping as well in the same tick. (Team1_Bill overlaps Team2_Nathan, and Team1_Jim overlaps Team2_Sam), might be difficult to parse out if Team1_Bill overlapped Nathan or Sam.
The FPS benchmark is about even for both collision systems until approximately 1000 are on screen, at which point the Team1 overlap Team2 Event routine starts to see marked improvements.
Benchmarking Capx attached.
Users browsing this forum: No registered users and 0 guests