Controlling player movement in the game

Is there any way to control/limit player movement in the game. I have created a terrain of golf course and would like allow player to move only certain parts of the terrain (middle of the fairway). I have bought a 3rd person camera pack from UnityPrefabs.com and I am quite satisfyed with the way I can control the camera. Anyway, I would like to create sort of ”virtual rail” (see the image) that the player can only move on. By doing this player could move front/back along the rail with arrow keys and rotate the wiev with mouse. Is there any tool in Unity that can create this kind of ”virtual rail” or is the any other alternatives that you can imagine? For example, should I create invisible tube that the player can move in?

You could just create an invisible collision all the way down the course using Cubes etc, con straining the character to a set path?

You could force them to die after every shot and then re-spawn where the ball has landed in theory. You could probably make the spawn point the child of the ball so it knows where to spawn you in relation to the ball. You would have to constrain this for when the ball is out of bounds or in a lake etc.

Thanks for the advice podda999! I tried to create this kind of “rail” but I can’t move the player smoothly. I have created the object(rail) in Sketchup and imported it as obj-file. Then I just attached a Mesh Collider component to the object.

Do you have any ideas how I could make the player move smooth inside the object. I am just a beginner with Unity3D so I am not sure if you are actually explaining this in the second part of your reply.

I’d think it would be best to have the walls at the edges of the course. Maybe you’re trying to limit view?

But what if the ball is in the rough? If it is a game you’d want to go to the ball correct?


Podda’s point in the second paragraph is just to place the player at the ball at the end of each shot, so the player wouldn’t walk there. They’d just die/respan/teleport there.
That’s how tiger Woods PGA works, you never actually walk, just appear at the ball when it’s your turn.
Probably not what you want.

Is this supposed to be just a ‘walkthrough’, or a playable game?

If you just want the player to follow a path, you might want to try a spline path. I think it can be done, but I can’t tell you how. I know I’ve seen thing around for splines (add ons, forums, main unity Docs -see top of page… I’m not sure)