What is the best way to go about having a system where the player can add or take away pieces of a pipe… And the end of the nozzle would shoot steam out. Basically the big problem is having a series of pipes connected and functioning like a real steam pipe would. If you sever the connection somewhere in the middle. Unity would be able to path solve the pipes that are connected and place the particle emitter at the the point of termination in the pipeline.
Basically it would have to know where the nozzles are facing between to determine where the end point for the exhaust might be.
I was thinking that that all the objects would have to be the same size perhaps to fit into a grid like space. And that pipes can only turn at right angles. But it would still be able to move in all 3 dimensions. Would an array be the best way to do this?
I would say maybe think out your concept a little more, not many people can help you on the forums unless you have your idea really thought out and just need a little technical help. What your asking is to have someone design the game’s mechanics for you.
For some basic help, find a suitable way to have your pipe move in 3D and just make the object’s position round to an integer to it aligns with the grid
And to rotate use transform.Rotation(90,0,0) and just change which value has the 90 depending on what axis you want to rotate on
I can’t really tell you how to do this, but hopefully I can get you started. If you have any more questions don’t hesitate to PM on the forums. Hope this helped
Then you can just raycast out the direction the pipe is going a short distance so it only hits the a pipe in the next spot. Check is the rules match. Then repeat until rules don’t match or you reach the end.
This is assuming all pipes have one in and one out.
Raycasts are pretty common and don’t tax the machine much, to make it really efficient though you just have to find ways to not call them.
For example, you don’t need to call a raycast when the pipes aren’t moving, because if they haven’t moved then the raycast will always be the same.
So maybe write some code that only checks raycast when the pipe is placed or moved, and only that pipe. Then you’ll only have a max of 2 raycasts running at each time
So that works. Problem however… Is checking for pipe turns vs straight pipes that are just in front of straight pipes. Right now it can’t tell the difference between the two.
why do you need to “work out” which pipes are connected to which pipes?
The pipes aren’t going to change shape once placed, and you’re managing the placement of them (i assume based on player input)… so each pipe can store what it is connected to when it’s placed. Then you just need a function to “pass” a boolean (aka isConnectedToSteamSource) along to the connected pipes. If a pipe isConnectedToSteamSource and has a connection that doesn’t have a pipe in it… you’ve got your steam particle effect location.