Hello, i’m trying to replicate something along the lines of this. I’m wanting to make it so there is just like one rock, and if I have a rock in my inventory and hit E, the while outline goes away and the rock goes in said place.
Im guessing each “piece” of the structure is its own object during the build phase and has an all encompassing collider to detect input when the player is looking at it (raycast). It probably searches through the items it needs and checks the inventory of the player at the same time, returning true on the first found item. When found it takes the item from the inventory and changes the material of a corresponding object in the building. The transparent effect is a shader, easily reproduced by creating a new transparent material and applying it to any mesh. My guess is the mesh is never really “swapped”, just the material applied to the mesh.
So an overview of the steps taken…
- When the player interacts, the system
checks to see what they are looking
at and if it can be interacted with. - If the interacted object is a
structure to be built, it does
another check to see if the players
inventory contains an item that it
needs. - If it finds the item in the players
inventory, it removes it from the
inventory and swaps whatever objects
material that item corresponds to in
the structure to be built. - The structure does one final check to
see if every required item has been
placed, if true, it probably removes
all the existing objects and swaps in
a combined mesh object + any
additional logic that allows the
player to interact with this
structure further.
Start simple and build up. Have an object in your scene that you can look at and interact with. Next have it swap materials when interacted with. Next have it remove an item from the players inventory. Step by step and eventually youll have it.