Ignore Default Gravity In Pipeline

Ah just looked at your image again. you walking inside pipe, not outside of the pipe?
If inside, then vector need push away from center.

Other than that

  • You know where is the pipe. You can either cache gameObject, ray cast, or detect on collision.
  • You know orientation of the pipe, or pipes
  • You know length (scale). Most likely forward z axis.
  • You know position of player / cube
  • What you need, is a distance from cross section center.
  • Therefore, what you need, is project calculated distance vector from center of pipe object, to pipe forward vector.

Something like that (for pushing outised) (untested may not work directly), but you get an idea.

Vector3 vectorFromPipeCenter = cubePosition - pipeCenter ;
Vector forwardPipeVector = pipeRotation * Vector3.forward ;
// or
Vector forwardPipeVector = pipeTransform.forward ;
// And finally
Vector project2Center = Vector3.Project ( vectorFromPipeCenter, forwardPipeVector ) ;
float radiusFromCrossectionCenter = project2Center.magniude ;