Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Seperate and Combine multiple 3D object

Discussion in 'General Discussion' started by thuiyang, Apr 14, 2020.

  1. thuiyang

    thuiyang

    Joined:
    Apr 14, 2020
    Posts:
    4
    Greetings,

    I am still new in Unity, is there any tutorial to seperate and combine multiple 3D object?
    For example, I have 4 small cubes, after I click on it/button, it will combine and become 1 big cube. Click again, it will reset to 4 small cubes again.
    I can only find the combine function in Unity Docs, is there any tutorial or video that is online now regards to my question? Thanks.
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,554
    There isn't going to be tutorial for that.
    This kind of behavior has to be scripted, and your game logic should decide when cube splits into smaller ones.
     
    thuiyang and Joe-Censored like this.
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    There's several ways to approach this. You could have the 4 cubes just assembled in the shape of 1 large cube, so it looks like 1 but is actually still 4. You could destroy the 4 cubes and instantiate a single cube, and the reverse. You could destroy 3 of the cubes and increase the scale of 1 of the cubes to the size of the combined cube. You could actually combine the meshes of the cubes (probably most complicated approach, but is more literal to what you are asking about). There's even a voxel approach. Probably a lot more options as well.

    Since what you're asking for is very specific, as already mentioned you're not going to find a tutorial which does it exactly. You'll have to do some investigation on your own as to what kind of approach is probably best for your purposes, and find information related to it. Maybe in some seemingly unrelated tutorial, maybe in a forum thread, etc.
     
    thuiyang likes this.
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,754
    The behaviour and basics logic is rather simple.
    But there are tons of ways, to approach the problem.
    Spending some time with Unity, will clear path which approach is suitable for your project.

    As already mentiomed, I am also in doubt, you will find any specific reading on the topic.
    You are more likely find more technical subjects, which are, or may be related.
    For example marching cubes. But that may be completely unnecessary and complex in your use case. On contrary, appointed simple Game Objects manipulations may be sufficient.
     
    thuiyang likes this.