Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Exploding Enemies

Discussion in 'Animation' started by Hydrax, Aug 28, 2014.

  1. Hydrax

    Hydrax

    Joined:
    Aug 2, 2014
    Posts:
    18
    Hi there.

    I have made a small doom-style game with some enemies made out of cubes that I have created in Maya LT and I would like to have them explode into pieces when they are killed, kind of like the enemies in Lego games.

    Now I'm not sure if this is purely an animation thing or something I might need to do in code or both(I code in C#) and any help or advice is greatly appreciated!
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,523
    When an enemy is killed, replace it with a prefab of individual cubes, and apply a force in the direction of the player's shot. Unity's Physics will take care of the rest.
     
  3. Hydrax

    Hydrax

    Joined:
    Aug 2, 2014
    Posts:
    18
    Hi Tony. Thanks a lot for your reply. I was think that the enemies individual pieces will fall apart (imagine shooting a person made out of Lego or blocks or something). Here is a picture of the enemy. Any more help you can give would be great!


    Robot.JPG
     
    BrandyStarbrite likes this.
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,523
    The enemy's mesh looks like it's made out of 13 primitives. Make another version of this enemy made out of 13 separate GameObjects, each with its own mesh/primitive, and save it as a prefab. When the enemy dies, destroy the original GameObject and instantiate the prefab in its place. Then apply a Physics force to the GameObjects.

    If you want to get more elaborate, look into Exploder or this alternative, Mesh Explosion, Fracturing & Destruction, or similar products on the Asset Store.
     
  5. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766
    Just add another thought here. if your mesh is modeled separately, you could just make an animation of falling apart.

    This is a collapse animation I used to make,
     
    BrandyStarbrite likes this.
  6. Hydrax

    Hydrax

    Joined:
    Aug 2, 2014
    Posts:
    18
    Thanks again Tony. I have decided to use the Cell Fracture feature within Blender which gives me a really good looking crumble effect to the enemy.

    Once again thank you for your suggestions and I will definitely keep them in mind!
     
  7. Hydrax

    Hydrax

    Joined:
    Aug 2, 2014
    Posts:
    18
    That collapse animation does look pretty cool. As I said in my previous post I am using the Cell Fracture feature in Blender to give me the desired effect.

    Thanks for your reply!