Move Spheres In a Hollow Cylinder

Currently I’m using addforce to push the balls in a hollow pipe cylinder which has some turns and I use if condition to see when to turn or not. The pipe has a mesh collider and the ball has sphere collider.

However, I find it’s very tricky to control using if condition all the time. Especially when there are a lot of balls and there are many turns of the pipe. Is there a better way to implement this?

If it were me, I would have the pipes controlling all balls within them rather than each ball deciding what to do. I would have a trigger-enabled box collider attached to each section of pipe which adds force to anything within it.

maybe something like

function OnTriggerStay(other:rigidbody){
other.addforce(0,1,0);
}