Making A Pipe System

Hi, Iā€™m absolutely clueless on how to make a little system that routes energy through pipes into this seller thing.

So I need it so that energy runs through the pipes and if the energy comes in contact with something it can interact with, it runs a function. But to somehow work with intersections.

The items will be placeable on a grid so that players can make any sort of order of pipes.
image

any thoughts or advice would be appreciated :grinning:

6 Likes

You have two options:

Easy to implement option:

Players set the direction of the pipes (for a 4-way they would set 3 inputs and 1 output) or you provide prefabs with preset directions.

User-friendly option:

Use maze-solving algorithms to find the shortest path to whatever target you need. This is also the most scalable option, as you can have multiple types of items/energy routed to different targets, whereas with the previous option, all inputs would be routed to the same destination.

For optimization purposes, you would calculate a path to the target:

  • When the generator is initially placed
  • Each time the route to the closest seller is changed
  • Each time a new seller is added to the pipes (it may be closer than the previously closest)

instead of every time you spawn a new unit of energy.

10 Likes