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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Is it good practice to have multiple meshes for one game object

Discussion in 'Scripting' started by DoomDude99, Feb 27, 2020.

  1. DoomDude99

    DoomDude99

    Joined:
    May 11, 2019
    Posts:
    87
    Some context:

    I'm working on a procedural livewallpaper and need to create objects dynamically in a scene. These objects
    are made up of several base components (most of which are recycled when creating new similar objects with additional transformations applied over them (scaling, animation, etc,).

    In short:

    objectA = { component1, component2 }
    objectB = { rotate(12', component1), component3 }

    I find it pretty difficult to create entire objects individually through code. Are there any better practices?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,971
    Procedural generation is going to require a lot more code than using Blender3D or any other 3D program.

    But the reason for doing procedural generation is that you can do things simply not possible with "pre-made" geometry.

    I believe Unity3D is simply hands-down the easiest engine in the whole world to do procgen with. Unity3D gives you full control over everything you need, but you still have to do the creative work yourself in the code.

    If you want examples, there are tons of tutorials. I also have a little procgen playground that I made public called MakeGeo. MakeGeo is presently hosted at these locations:

    https://bitbucket.org/kurtdekker/makegeo

    https://github.com/kurtdekker/makegeo

    https://gitlab.com/kurtdekker/makegeo

    https://sourceforge.net/p/makegeo
     
    DoomDude99 likes this.
  3. DoomDude99

    DoomDude99

    Joined:
    May 11, 2019
    Posts:
    87
    Thanks. I'm working on a destructible procgened environment (drive a tank through a house); The meshes you can create seem monolithic and parts of them cannot be recycled in other objects. It seems that unity lacks this granularity of building objects (similar to legos) from different meshes.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,971
    Unity has all the tools necessary for you to do this, but thy key is, it is up to YOU to do the geometry work: Unity simply lets you manipulate meshes at the vertex and triangle level, and it doesn't get any better than that. I mean the Probuilder folks wrote an entire 3D modeler INSIDE of Unity!

    As far as acting like Legos, it will always be better to pre-make a ton of varieties of how models can be destructed, then mix and match them. This keeps you from making degenerate-shaped objects, which can be very hard to code heuristic-wise.
     
    DoomDude99 likes this.