# Paths / Waypoints

I am making a game that requires a car to follow a PRECISE track.
I will start by making a world editor/maker in which I will create every level.
The road will be split into pieces that can be built together to make a full road.
So how to assign to each block a path to follow?
PS: Each parts will have two parallel roads, and the car needs to travel in curves also.
So how is this possible? can anyone point me to any resources?

In short is it possible to make a Prefab with a path assigned to it that can be combined with other prefabs to make 1 whole path? And what is that resource?

So how is this possible? can anyone point me to any resources?

Yes, almost everything is possible and have a infinite way to do. Here is a good starting resource:

http://docs.unity3d.com/Documentation/Manual/Scripting42.html

I have found a solution to use iTween script located here:
http://pixelplacement.com/2010/12/03/visual-editor-for-itween-motion-paths/
Now I am trying to figure out how to make a grid based terrain to add these paths dynamically.
The best approach in my opinion is that every part has a script that indicates the path’s behavior on it (starts on X relative to the cube and so on).
Then when the whole terrain is created the code should create a whole new complete path according the the combination.
I answered my own question I guess

Here’s an idea, but it is a bit limiting:

You can pre-create several road “tiles”, say for instance vertical road, horizontal road, and the 4 curves (bot/right, bot/left, top/right, top/left).
Then for each one of the tiles, you’d define the location of the car in relation to the entry point for that tile. For example, a straight line would have the following function:

(x, y)(d) = (d, 0.5)

As in, the X coordinates equals D, which is the distance travelled from the leftmost point of the tile, while the Y coordinates are a constant 0.5.
You can define the function as a script:

``````public Vector2 GetPositionInTile(distance) {
return new Vector2(distance, 0.5f);
}
``````

Then as the car is travelling the road, you calculate the distance as a function of the car’s speed and time, and then depending on the tile that the car is in, you calculate X and Y using the tile’s function, and move the car to the correct position every frame.