Hey guys how are you doing?
I have been studying game development for a while, tried a few engines but ended up with monogame because of C#, and I’m loving it!
I’m developing a top down game with lots of monsters that is visually like vampire survivors (but not mechanically). I have coded pathfinding for the enemies, which they use from time to time, and now I would like to implement collision detection for them to collide with each other and not overlap.
My first approach was to create 4 rectangles for each enemy, one rectangle for each direction. They are:
collisionRight: 1x16px, right of the hitbox.
collisionLeft: 1x16, left side pf the hitbox.
collisionUp: 16x1, up side of the hitbox.
collisionDown:…
Each update, I calculate the rectangles positions based on the enemy location and its movement speed. The collision is working as expected, but when I instantiate like 15 enemies on the scene, man, the frame rate goes down to 2fps! It’s kind of funny, I programmed kind of what came to mind, I really didn’t think this would be a problem at all.
What do you guys think? Is this like a common issue (or like a non issue at all because everybody knows this approach doesnt work, except me, lol)?
I was reading that there are other ways out there to implement collision detection, but do you guys think it is even viable to have like 80 enemies at the same time, colliding with each other? That got me thinking.
Also, is “intersects” an expensive operation?
I will give you an example of why I wanted collision detection for the enemies. Lets take the bat enemy…
The bat does not move in a straight like, if its moving right, it will bounce up and down a little bit as it goes. So, in this bouncing, it may collide with another enemy (or a wall), and should not overlap with it. Each bat enemy may of may not be following a path from astar.
Well that would be it.
Sorry for the long post.