Stay in a pipe

I am working on a game where players fly on rails through a pipe.

The solution I have at present is that when you approach a turn you hit a trigger and turn 90 degrees over time. This works as long as the turn is 90 degrees and only at one speed.

I am looking for some suggestions of a better way of doing this so I can have any shape turn at any speed.

Below is a video of the prototype

Any help is most appreciated.

Kenny

One way to accomplish that would be to cast a ray to either side of the bend. Make the player ship keep a constant distance from the hit point of the raycast, and rotate the ship so that its rotation is perpendicular to the surface normal of the raycast hit point on the matching axis. This way it will work inside any pipe, though you have to make sure you are casting rays on the right plane - that is, if the bend turns left or right, you have to shoot the ray left or right, not up or down.