Practical solutions for lag reduction?

I have a problem with a game system I have so far, there’s no problems with any code, the enemies are made of many many little bits you can blow off with guns(The head alone has 35 parts.)

The issue is, that the frame rate exponentially halves for every enemy in the level. 8 at once makes me have to quit unity through task manager.

Is there a way to reduce the amount that unity will lag without reducing the enemies bits?

Pictures show an example of what I mean by blowing bits off.

First of all, there is no need to have that many bits at all times. Have a solid block for the head, another block for the body, arms, etc. Only when you hit one of the blocks, replace it with the little blocks. This way, your frame rate won’t suffer before spawning lots of the little blocks.

I.e. have your characters made up of a few, large blocks rather than lot’s of small ones. Only when you hit them, replace the hit part with the block composing of lots of smaller ones.

Don’t keep all the little blocks on the scene. Have a timer or distance-from-player script on them and destroy them after a while. Maybe even destroy them straight away after they go out of the camera’s view? Or maybe destroy them once a certain distance from the player has been reached?

  • Additional info: have tags on the large blocks identifying the part (eg head, arm) and have a ready prefab with the small blocks for that part. When you hit a part and the object has a tag = “head”, then destroy the object and instantiate your complex ‘head’ prefab in its position, parenting it to the old head’s transform.parent.