Most efficient way to find models' look vectors which are next to a part?

Here’s he idea:

Right now I basically have a game where the goal is to get minerals through a system of upgrades and modifiers in the most efficient way possible. Here’s an example of what a super basic factory in game looks like:

Here’s the problem:

The build system works fine, but the main issue I’m having is getting everything to be as intuitive as possible for the player. Right now the way you have to build your factory is by looking at the direction of the tube in the build menu, and placing it down to follow the direction of your tubes. I want it so that things are more automatic. For example, if you are placing a straight tube in the wrong direction, I want it to automatically have it go in the right direction based on the tubes that are around it. Another example would be a corner tube going in a direction based on the tube behind it so that you wouldnt have to think about the direction of the corner pieces on your own.

Build menu SC:

Build_menu

Placing in action:

Solutions I’ve thought of:

I’ve tried GetTouchingParts() and a simple touch function to activate when the conveyor model is being placed down, but these events don’t seem to work too well with parts that are anchored and placed so suddenly. They only seem to activate when the part is moving.

I’ve thought about raycasting, but I’m not sure how I would execute it in this scenario.

If you guys have any ideas, please let me know. Been a bit frustrating trying to think of a solution to this lol

Do you have a table set up like a grid to store the pipes?

Something like that would make it trivial to retrieve information on surrounding objects.

1 Like

If you can’t have a grid system like pheonix suggested, then raycasting would be your best option:

when a player places the the tube, you can create a ray from where the tube will connect. If the ray detects another tube object, then connect the 2 tubes.