I am trying to make a game like Please login to see this link. with an extremely large amount of enemies, items, and projectiles on screen at once.
The one issue I can't seem to figure out is preventing enemies from all gathering on top of each other without severely limiting how many I can spawn or plummeting the frame rate.
I've kept their AI about as simple as it can possibly be:
Always
+Set direct to "ATan2(yPos( "Active" ) - 180, 320 - xPos( "Active" ))"
+Add "Cos(direct( "Active" )) * 1" to xPos
+Subtract "Sin(direct( "Active" )) * 1" from yPos
+Set X Position to xPos
+Set Y Position to yPos
This is really all I need the enemies to do as far as AI. They move toward the player in the center of the screen, dont have any obstacles to collide with or anything.
With these events alone I can spawn over 4000 enemies before the fps begins to dip below 60.
Problem is they all gather on top of each other since there's no collision detection or anything.
I have spent the last few days digging through this forum looking for a way to keep them from overlapping while keeping enemy count and frame rate as high as possible, but I haven't been able to find a solution thats good enough. Every method has sunk the possible enemy count down to around 100 or less before frame rate starts dipping below 60 and thats just the enemies alone, keep in mind I'd still need tons of item drops and projectiles as well. Look at the video of Vampire Survivors I linked above to get an idea of what I'm trying to do.
So does anyone have any ideas? I was thinking the solution might not even *necessarily* be collision detection. I'm assuming thats whats needed, but maybe since enemies dont need to collide with walls or anything, maybe there's some other more perfomance friendly way of telling them "don't stand on top of each other".
I found an interesting approach Please login to see this link. that doesn't even use the "collides with" or "is overlapping" functions, instead using coordinates and variables, but this example is really old and still not quite well performing enough.
But it got me thinking that there might be some kind of creative solution to this problem.
Or I don't know, maybe a collision event is required. I'm open to whatever approach, I just want to get as close to the amount of stuff on screen as Vampire Survivors that CTF2.5 is capable of pulling off at 60 fps.