Search Unity

Sprite Slicing During Runtime

Discussion in '2D' started by Manillan01, Apr 21, 2017.

  1. Manillan01

    Manillan01

    Joined:
    Feb 15, 2016
    Posts:
    5
    I am creating a game with explosions and I want to add a feature that when something explodes, it shatters into pieces. I have no idea how to go about slicing a sprite during runtime or how to assign them to new gameobjects. Does anyone know how to do this?

    Thanks
     
  2. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    136
    An interesting question.

    I think this is usually done by just removing a GameObject and replacing it with pre-made parts. It's the easiest way. But it's only good if you don't need a real precise slicing.

    Doing a realistic slicing will require some advanced coding. I think you'll need to get sprite's mesh, write an algorithm to break it into few meshes and create few GameObjects with those meshes and same material. But there can be more to it than that.

    Also, I've found this asset that does exactly what you want.
     
    theANMATOR2b likes this.