@MelvMay That is not accurate or feasible as Unity only supports a limited number of layers. Also that normally how its done in. That type of thinking only works with small single player games of a specific type and tech demos.
As Shitman says you can’t have every tank on a different layer. Splitting things onto layers isn’t feasible for most mid to large size games.
@MelvMay I’d really like to know if your comment about IgnoreCollision is based on a performance issue with the system. If so that would be a huge disappointment as we waited for months to get this issue fixed and are about to move our system back over from the trigger hack described below.
@Shitman
I have not profiled ignore collision yet. I had to rip it out previously due to a bug were it was resetting trigger states when used (look up my posts on ignore collision) but this was fixed in 5.5.
My hack to get around the bug currently has all my projectiles with triggers, so I can early out in code. (they collide with there own hitboxes but know to ignore hit boxes from their owner) Sadly this meant that all my collisions impulses are manual.
Now that Ignore Collision is fixed we will be moving over to this system, I’ll let you know what we find though it may be a few weeks before we have the time.
I would suggest the following (I have not tried this yet but hopefully the physics system remembers ignores when an object is disabled):
I would pre-create a bunch of tanks and units on startup. Then disable the gameobjects (pool them).
Do the same for their projectiles.
Now assuming you can’t pre-pool projectiles for every tank ( maybe you can if each tank only would have one or two shots in flight at a time. If you can then just have the projectiles ignore tank collision on startup.)
-when a tank is being created I’d “assign it” a set of disabled projectiles and have them ignore its collision. You can space this out over several frames if performance is an issue.
-Then when shooting the projectiles simple enable them rather then creating them.
-When they hit disable the projectiles, reset their values and have the tank reuse them.
Hopefully the projectiles will remember the ignore collision on disable and you wont have to re-create. If they don’t remember the collisions I’d open a bug as the system was implemented in a way that wont really fix the issues its meant to fix.