Constrain Flying Player to a Corridor


I Would like to have my player (from the flying template) flying through a tube. The tube has curves and twists and the forward movement of the player should basicly follow a"path"in the middle of the tube corridor. Ideally the player should rotate back to the path in center of the the tube if the offset from it gets to big, like what modern cars are doing if you leave your lane, but in 3D. Unfortunately i doesn’t have any idea how to start? Dose anybody know how i could do this with blueprint?

You probably want to use splines to create the path for your player to follow.

This tutorial should give you an idea of how to get a pawn/actor to follow a spline path Obviously you’d need to modify this approach to your exact needs i.e. allowing the player to move off the spline etc. But hopefully this should give you somewhere to get started.

One idea for the player movement is to have an empty/dummy object that does the path following and then have your player as a child of this object which is free to move in relation to the parent object. I had something similar implemented in blueprints.

With regards to limiting movement off the path, you’d probably want to have a value that you check against and then use something like VInterpTo to bring the player back onto the path.

Thank you very much the idea of using a parent object that is constrained to the spline sounds very promising, i will give it a try.

Here’s a basic skeleton of what I suggested. Hopefully it’ll give you a start.

You’ll need to open the Corridor_Test map manually in the Unreal Editor as there’s no game mode to load defaults etc. Use WASD to move the player within the camera view, although the movement is far from perfect and doesn’t include your idea of returning to the path.

Everything else should be fairly clear if you’ve looked at the link in my previous reply.

Great thank you, i stuck in the tutorial you have linked because i cant find the variable type Spline_C, i will look in your example now