Hi, this is a question mainly about 2D development, but a 3D guru may still be able to answer it … hopefully!
I am developing a 2D space shooter. My camera is orthographic and I am using 2D sprites. Everything is fine in terms of movement and collision. I tend to run my game at 240FPS just to see if any level has a performance hit.
On my 3rd level, the FPS drops a fair bit simply because my space invader enemies on this level are generally overlapping each other as they move. I only have 26 of them and they are all rendered on the same Z position.
My spaceship and spaceship laser are also on the same Z position. This enables the laser (and space invader) to generate overlap events when they collide.
If I render the 26 enemies with a Z position of 1 pixel apart, then there is no slowdown! But I can’t do this as my spaceship laser needs to collide with the enemy on the same Z position!
I’m guessing the slowdown is due to Z-fighting.
I don’t really know a way around this.
Any help would be appreciated.