How do I make a racing car turn more smoothly when traversing waypoints?

In a racing game, I have set up waypoints for the player to follow.

I have added many waypoints to give an illusion of curved movement.

However, the player car turns instantaneously when passing each point, which is especially jarring because the camera is following their rotation.

How can I make the player's movement a more natural curve?

I'm using C# in Unity.

• You want to add a steering behavior to your vehicles. I suggest using Quaternion.Lerp for smooth rotation Sep 1, 2015 at 6:51
• this is what I am using for rotation, Quaternion target = Quaternion.LookRotation(playerCOntroller.currentWayPoint.position - transform.position); transform.rotation = Quaternion.RotateTowards(transform.rotation, target, playerCOntroller.speed); Sep 1, 2015 at 7:15

You basically have an ordered list of segments, making the segmented path you have described of that road. To smooth it up, you could simply take the centers of the segments and the points connecting them to create Bézeir curves from them.

Read here for a detailed explanation of how it's done.

Once you describe the path as connected Bézeir curves, it's already smooth. Now you just need to configure the vehicles to follow that path. The easiest way to do that is by generating enough points on the path at run time so you basically get many tiny segments. You can also do a kind of binary search on the curve with the t variable, by starting with a small increment and then doubling it until it's too far off and then doing a regular binary search over between the too far off value and half of it. Obviously, generating the spline is more cost efficient amortized.

Well I don't know much about way points but there is another way to rotate your objects on the circular track.

You can use unity iTween by which u will have to take few nodes and will be able to place them as u want and then one script is there for iTween which u will apply on the gameobject then I think it will work.

Here u go... http://itween.pixelplacement.com/index.php

• yes I heard of iTween but was not sure it can be used for racing game ,can we use it flexibly for racing game? rank of players ,diffrent speed for players etc? Sep 1, 2015 at 7:34
• Yes we can... But for that u will have to give some reference points like rotation from a particular position on track and all. All I know is that iTween provides a path with the help of nodes. Sep 1, 2015 at 8:38

You can use iTween Visual Path editor. Its a nice tool to move object on a particular path. I usually use it for cinematic camera movement. Also many of the parameters regarding the path will be exposed to the user. You can start and end at any point on the path, need not be from start point to end point. Also can force the look at angle of the moving object according to the path nodes.

If you want to make a car racing game its more appropriate to make a Car AI system.

Here is a nice tutorial:- https://www.youtube.com/watch?v=HeQ89e27ehc

• yes I heard of iTween but was not sure it can be used for racing game ,can we use it flexibly for racing game? rank of players ,diffrent speed for players etc? Sep 1, 2015 at 7:34
• edited the answer :) Sep 1, 2015 at 7:45
• thanks @Hash ,actually I am using moveTowards function to move players since player's positions are restricted on lanes.So not using physics Sep 1, 2015 at 7:48
• ohh in that case iTween is a good option :) You can try adding some tweaks to the code so that the amateur drivers don't follow the exact path , and the good drivers follow it thoroughly and yea also the speed parameter. Sep 1, 2015 at 7:52

As solution, without other tools, you can consider to start (smoothely) turn to next waypoint before you reach the current target waypoint.

Hope the image clarify my idea. When you reach the green circles (the size can depend on waypoints distances) start to turn versus next waypoint

• thats pretty good solution, will implement it and let you know Sep 1, 2015 at 12:30
• If I've understood correctly, that would look like the vehicle is sliding awkwardly because it will rotate without changing it's velocity. Sep 20, 2015 at 23:55