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
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.