- Home /
2d physics for cars. The game from the top down
Hello! I want to do for physics 2d car but I can not understand, I have only recently started to learn unity. Now I have a car goes forward and turns. I have two questions for proper implementation? And how to make the car turn, it was impossible to make a U-turn on the spot. Should I use a wheel component? Here is my code https://www.dropbox.com/s/ficybob11uek992/Vehicle.cs?dl=0 Pay attention to the function updateVelocity.
An example of what I want to get http://www.youtube.com/watch?v=7tuAcN7W40k I really hope for your help! I will be happy if you provide your version of the machine control via rigidbody2d. Thanks!
If you use 2D physics, don'T use the wheel component as it's designed for 3D. To stop the car from turning on the spot, make it's turn speed relative to it's move speed (if the doesn't move at all, turn speed is 0 so it won't turn).
Answer by Garross · Aug 02, 2015 at 07:27 PM
To make the car do U turns add a .Slerp to your rotation. Like so: transform.rotation = Quaternion.Slerp(transform.rotation,rotation, Time.deltaTime * damping);