Mouse drag through Maze without relying on collision

Hey everyone

We are currently working on a puzzle game that involves a cube you can rotate. On the cube you can find several puzzles you have to solve to slowly deconstruct the cube.

For one of the puzzles we designed and modeled a 3D Maze that you are supposed to drag several objects through along different paths to the center.

To code a function that allowed us to drag the object via mouse wan’t an issue but we dont know how to make sure that the Player has to stay within the boundaries of the path. We could do this with physics using collision but since that’s prone to glitches we would like to find a different approach.

Has anybody any idea how to approach this? c# would be preferred since none of us have worked with JavaScript before

Thank you

The first thing I think of would be using Unity’s navigation and pathfinding system. The floor (being marked “Navigation static”) and the walls of your maze would define a navmesh. Your ball would be given the Navmesh Agent component. You wouldn’t drag the ball itself, but a “dummy” object (not visible).

At runtime, the ball would move to the closest location on the path near the dragged dummy, without having to worry about collisions or physics.

See documentation : Unity - Manual: Navigation and Pathfinding