Movement on a tube

I’m working on a game similar to Sonic Lost World, and I need to get the movement on a tube-like level like in that. I’ve tried turning off physics and seeing the gravity to always be downwards relative to the player, and unfortunately that didn’t work. The closest thing I can find to this problem is moving on a sphere like in Mario Galaxy, which doesn’t work at all with the tube-like level because the player will just gravitate towards the level’s pivot point instead of keeping the mesh upright at any angle.

raycast down. get the terrains normal, use the terrains normal (which will be your up) + the characters transform.right in a vector.cross(…) to get the new transform.lookat(…)
That will allow you to always be “level” on the ground.

for a brief PSEUDO code example


Vector3 Right = transform.right;

RaycastHit Hit;

Physics.Raycast(transform.position,-transform.up, out Hit)

Vector3 Up = Hit.normal;

Vector3 Forward = Vector3.Cross(Right,Up);

Vector3 LookPos = transform.position + Forward;

Void Update()

Message if you need any help understanding or coding.