1
\$\begingroup\$

I'm currently collecting ideas how to make a building and placement system in Unity.

The user can place the game objects on several layers or floors, but the objects need to be on top of the objects beneath. It can't hang in thin air. The layers could be in theory infinite.

First idea, to have several planes with a grid system where the user can place the objects. Each layer is its own plane and the objects are child elements of the plane, storing the positions of the objects of each layer and displaying the outline of the game objects beneath the current layer.

Second idea, having only one plane with a grid system and placing the game objects.

Any other ideas?

\$\endgroup\$
3
  • 3
    \$\begingroup\$ generally not a good idea to ask for ideas on stack, you should gather ideas, try them out, and if they don't work. Explain how they don't work, and then ask for a solution. \$\endgroup\$
    – Pow
    Feb 1 at 13:06
  • 2
    \$\begingroup\$ What do you find less than "satisfactory" (🥁) about the methods you've thought of so far? In what specific ways should answers try to improve on these proposals, or by what criteria should we rank answers using votes? \$\endgroup\$
    – DMGregory
    Feb 1 at 13:35
  • \$\begingroup\$ @DMGregory I'm not that familiar with building systems, so my thoughts may not make sense or be too naive. So any other related ideas are most welcome. \$\endgroup\$
    – RBull
    Feb 1 at 15:10

2 Answers 2

0
\$\begingroup\$

As far as I can tell from playing Satisfactory, it seems to not have a global grid. Objects can be freely placed anywhere in the world.

However, some objects (i.e. foundations) create an ad-hoc local grid when placed. Other objects can then be attached to that grid by placing them on a foundation-type object that is already part of the grid. This limits their orientation to 90° angles relative to the grid and positions to fixed grid increments, so the whole grid becomes neatly arranged.

How would I implement a system like that in pseudo-code?

when the player places a building
    perform a raycast from camera into the world
    if there is a hit
        if the hit is on the terrain
            allow free placement of the object
            if the placed object is a foundation object
                create a local grid aligned to the rotation and position of the object
                make the newly placed object the first member of that grid
        if the hit is on a non-foundation object
            deny placement
        if the hit is on a foundation-object
            get the grid the object is a member of
            snap position and orientation to the grid
            make the object a member of the same grid
\$\endgroup\$
2
  • \$\begingroup\$ thank you for your answer. \$\endgroup\$
    – RBull
    Feb 5 at 9:29
  • \$\begingroup\$ @RBull When this answer answered your question, please accept it by clicking the checkmark-icon next to it. \$\endgroup\$
    – Philipp
    Feb 5 at 10:30
0
\$\begingroup\$

How I would solve it would not involve multiple planes but rather a single one.

A grid for placement is displayed at the intercetion shadow building with the world. You will have three different states I can think of

  • Collision with the default world
  • Collision with an uneven building top
  • Collision from the side

Your life will be a lot easier if you allow to build only buildings on top of platforms. This will allow you in the default world to have a ground that is not straigt by simply extending the platform downwards and offering an even surface afterwards.

When you try to place a platform on top of an existing structure, the building grid can be calculated by storing (not neccessary on the object itself) the buildings/ producer height. Since all buildings are placed straight, any point from the bottom of the building to the stored max size will allow an easy placement on top of something without having a weird 2/3 stacked building next to each other/ partially overlapping. You can make your life even easier if all buildings are either having the same total height or only a few total heights overall.

Side collisions can be solved again with platforms. If buildings can be only placed on them, you ignore the collision and use the last valid location you had. This means you would not display a shadow outline when the initial hit for a building is on a second building. The first hit with a platform will display the shadow building. If you snap the building to the grid already, it will have a similar feel for the player in the regard that the shadow is not updating the location all the time. A hovering from platform to build building to platform might look similar from updating the location between grid locations. If the distance between last valid hit and current hit is too big (like pointing the mouse over a long building complex), you could simply hide the shadow image again until the next platform hit.

You will face another problem with an inifite layer approach or allowed building height though.. The target hardware will only be able to handle so much. If you offer your player infinite layers, they will use those. The buildings won't be taking too many ressources itself but conveyor belts with items on it might get really fast on the limit what you can handle. Depending on how you create the visuals on it, how far they can travel in your game, how far from the player they can run/ be active, etc. The placing of objects in comparison is simpler

\$\endgroup\$
3
  • \$\begingroup\$ Thank you for your suggestions. What exactly do you mean with platform? Top of the gameobject? Floor elements? There will be only a couple of different heights for the objects, but some rules what can be placed on top of another. \$\endgroup\$
    – RBull
    Feb 1 at 15:14
  • \$\begingroup\$ @RBull with platform i mean in Satisfactory terms the object FICSIT Foundation or one of its siblings. \$\endgroup\$
    – Zibelas
    Feb 1 at 15:38
  • \$\begingroup\$ thank you for clarification. \$\endgroup\$
    – RBull
    Feb 2 at 6:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .