Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

How to separate one GameObject into multiple pieces

Discussion in 'World Building' started by bassboosted_Tragedy, Jan 2, 2019.

  1. bassboosted_Tragedy


    Jan 1, 2019
    Sorry for another rookie question, but is it possible to break up a game object into other pieces? If so, how would I go about doing that? I assume this is much easier than I think it is, but I'm just playing it safe as to keep from breaking anything Thanks so much for any help.
  2. alussam


    May 13, 2018
    You shold use blender for this purpose or other similar application. In unity it is impossible
  3. Flavelius


    Jul 8, 2012
    Breaking gameobjects into pieces can be done by creating other gameobjects and putting some of the scripts from the first one onto these (if they don't have relative references to certain hierarchy elements). But you're most likely wanting to know how to split geometry/meshes; and that indeed should be done in a 3D-modelling package. It can be done inside unity, but is not recommended and can potentially be very complex, depending on the model.
  4. JoeStrout


    Jan 14, 2011
    Or, depending on what you're trying to do, you may find something in the asset store that does it. There is an asset called (IIRC) "Exploder" which does a pretty good job of exploding most meshes. Or, for Beatron 2000, I wrote a little script that breaks any mesh into its constituent triangles, and sends those flying (for a Tron-like explosion).
  5. gabrielw_unity


    Unity Technologies

    Feb 19, 2018
    Hi, you can use ProBuilder for this! :)

    1. Drop the mesh into your scene
    2. Open ProBuilder, select the mesh object in your scene, and click "ProBuilderize" (in the future, this will be seamless, sorry!)
    3. Use ProBuilder to select the faces you want to "break off" to a new mesh
    4. Click "Detach Faces" (note: you can click the little "+" next to the button to choose whether the faces become a new GameObject, or SubElement in the same mesh!)

    Hope that helps! Here's more info from the docs:
    ProBuilder: Detach Faces
    Kjelle69, Uncle_C and Chiefmastoras1 like this.
  6. gabrielw_unity


    Unity Technologies

    Feb 19, 2018
    Separete note: as others have mentioned, it is often best to do this in a separate editor (Blender, Maya, etc). Using ProBuilder is (for now) a somewhat clunky method, and will be tough if you have very complex mesh. However, if you just need a quick separation of chunks, and also want the benefit of further editing in-editor, ProBuilder will do the job nicely :)
    Uncle_C, Chiefmastoras1 and JoeStrout like this.
  7. Honorsoft


    Oct 31, 2016
    Just commenting because the advice here is lacking and pushes using 3rd-party 3D software to make "pre-broken" versions of models. It is possible to break apart things in Unity during runtime, without having to break apart objects in a 3D editor or ProBuilder and then switching objects during runtime. It is quite easy breaking a mesh apart into shards, chunks or any shape you want really. Two things to consider are models broken into vertice triangles will slow down Unity if there's too many of them. Also, meshes are hollow, so when you break them, you have to also weld the pieces so they look like solid chunks. It isn't hard to have the texture applied to the pieces so that the pieces keep their texture. I have written a script that creates a Voronoi fracture to any mesh object in Unity, and it also starts the Voronoi pattern generation from the initial collision point to give a realistic shatter to the mesh object. I will post a more basic version of the script here soon when I get some free time, but in the mean-time, read up on Unity's mesh filter component.

    Just as proof that it IS possible to break up a game object into other pieces and it will look realistic and work fast, here is a screen shot of a test-game running in Unity that uses different versions of object shattering in real-time, breaking the actual mesh into chunks:

    (The objects are the white ones which weren't textured yet, the grey square is just to hide the test-character.)
    The headless Statue of Liberty can be seen in here, broken in realtime and automatically welding the base model and the chunks to fill in the holes in the meshes. This was a test using Unity 5. I have more projects and some using Unity 2018 and 2019 and I will post more here soon. Not the best screenshot, but it is proof that even complex models can be easily broken in Unity, without Blender or premaking broken versions of the original object and swapping them, it also worked near-instantly fast, even on an old Windows 7 32-bit system.

    Here's a couple of demonstrations from others using Unity, shattering objects in realtime:


    All the pics posted are from Unity projects, and works on versions 5 through 2019 (maybe earlier too).
    Last edited: Sep 11, 2020
    Kjelle69 likes this.
  8. tclancey


    May 19, 2017
    Looking forward to some code for this, way beyond my head to work out,but I'd love to use something similar.