Search Unity

In game player construction options

Discussion in 'General Discussion' started by saharaborn79, Jan 23, 2021.

  1. saharaborn79

    saharaborn79

    Joined:
    Jan 13, 2021
    Posts:
    3
    Hi all,

    I'm still new to Unity and self taught so I'm having a hard time tracking something down even after hours of research so hopefully someone can answer this here.

    How do I set up my game to allow the player to create their in game (non-mod) construction. Examples
    of this would be the ability of any player to create structures like in ARK or Fallout 4. I'll even toss 7 Days
    to Die in although that construction is most likely (I assume) somewhat different.

    I want the player to be able to create foundations, walls, ceilings, stairs, windows, book shelves etc. and
    I want the player to be able to create exactly as they wish. Skyrim is what I DON'T want. Skyrim had
    a list of pre-fabs in game that you could choose from and then "build". I want the player to have complete
    control. Another example of what I want would be Night of the Dead with the ability to do the above including
    building construction benches, defenses etc.

    Any help on this would be great appreciated!
     
    Last edited: Jan 23, 2021
    perterliam likes this.
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    A foundation, wall or piece of furniture, once placed, is just a static object prefab in the world. You can just spawn those with Instantiate, except you need to write scripting to determine valid placement and perform snapping. You'll also need to store their positions in a save file and rebuild them once the game is loaded. And that's pretty much it.

    Inside the game, basically, construction goes like this:
    1. When placement start, spawn a "ghost" object.
    2. Have scripts that determine ghost's valid placement and snapping.
    3. If the user tries to place an object while placement is valid, spawn the prefab into the world with Instantiate at coordinates of the ghost, and prehaps record its position somewhere.

    Also, you only need to record where your objects are if you're doing some sort of conveyer system like space engineers.

    Another thing is that with more complex construction you'd need to perform optimizations.
     
    saharaborn79 likes this.
  3. saharaborn79

    saharaborn79

    Joined:
    Jan 13, 2021
    Posts:
    3
    Awesome response! Thank you very much!
     
  4. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    There are some assets in Asset Store to check (even free one exists!).

    *personal opinion here*
    But in general it's only about spawning assets or parts of those - there no in-game 3D modelling software (and for a good reason - players need a game to have fun, not a Blender/3Dsmax/Maya huge interface with tons of menus and hotkeys to learn to achieve ... what?). Simple stuff (like terrain building) probably will be nice to have, but if creation of content is harder than Minecraft block placement - it wont work for players, creating 3D stuff is hard and not so rewarding process... I'm personally making ray-tracing sandbox game but it's still only about placing existing library of assets and their parts and modifying them (material replacement, playing with lights, scale/move/rotate/delete stuff).

    Check out what's happened with Sony project "Dreams" in the end as example...
    */personal opinion*
     
  5. saharaborn79

    saharaborn79

    Joined:
    Jan 13, 2021
    Posts:
    3
    THANK you!

    This lead me exactly to what I needed. Unity assets is all about finding the key magic words to get results at times
    and the words are "In game Building System" or "In game Modular Building System" and your pack linked me to the
    goldmine!