Search Unity

Destruction of individual parts of an enemy

Discussion in '2D' started by Pau1, Mar 21, 2016.

  1. Pau1


    Mar 21, 2016

    I'm new to unity and have been fine getting done what I've needed without too many problems so far, but I've been stuck for a couple of days now with this problem.

    I have a sprite sheet with loads of different parts of alien ships, and I've got a system in place now that I can build new enemies with the parts and the scripts work well with sending messages (for instance destroying a part will destroy child parts, and damaging a part also sends damage to it's parent, so it's not disadvantageous for the player to destroy parts and not just always attack the main part).

    Anyway, I wanted to create an effect where upon destruction of a part, the part is divided into several pieces (maybe 2-4) and sent off into space with colliders and gradual rotation. They can be hit with projectiles, bounce off other ships and the force of explosions etc. should send them away.

    Initially I thought a particle system would be good for this, but the fact that the particles are made up of bits of another object, I'm unsure how I'd do that. I don't know if there's a way I can dynamically divide up the sprite, or I'd need a few different sprite sheets of each part divided into pieces several different ways that I can use for the pieces.

    Or alternatively because there's just a few pieces emitted right away, is a particle system even needed- should I just spawn some bits when a part is destroyed and send them off at some random velocity and rotation with collider and rigid bodies?
  2. geek_freek


    Aug 26, 2014
    Well Particle Systems would work as well , since you can use forces dynamically on the particle system so if your Player is hit from right , particles emit towards right and so on.
    With Particle System you can also use Sub-Emitters which can comprise of other stuff from your Players body , so the explosion would look dynamic as well.

    Your idea of using only 4-5 sprite parts individually can also be served with Particle Systems by decreasing the amount of particles emitted.