I’m working on a twin-stick spaceship shooter that should support a large number of AI controlled ships shooting simultaniously. As part of optimizing and dealing with problems with shots going over or under 3D objects I decided to use 2D physics and collisions. Another optimizing decision was to use pooling for bullet-objects.
I have now run into the problem that I set those pooled objects to ignore collisions with the collider of the ship that fired them, as the ship’s turrets are often within the collider. But while the Physics3D Ignore collision worked well for this, I found that the Physics2D variant wasn’t working, and the shots still collided with the parent ship. Looking at the documentation, apparently Physics2D’s ignore collision is removed when an object is set to inactive, which is what happens all the time with pooled objects. This limitation is apparently exclusive to Physics2D, Physics3D doesn’t have it.
Does anyone know why this is, and if there’s some way to have the same functionality without having to set the ignorecollision every time you get an object from the pool? Or am I forced to redo the ignore collision every time I fire a pooled bullet, and won’t that have a performance effect when there’s over a hundred guns firing?