- Home /
Duplicate Question
TOP down 2d car physics
What I want to do is make a car game that is viewed from the TOP down, as in you see the roof of the car. My problem is that I can accelerate, and rotate the sprite, but I can't make it turn realistically like the car in the car demo that unity provides. I also have no idea how to do this, and I just started using unity's 2d mode. Any help is appreciated.
var power : float = 3; var maxspeed : float = 20; var turnpower : float = 2;
var curspeed : float;
function Update () { if(Input.GetKey(KeyCode.W)) { rigidbody2D.AddForce(transform.up * power); }
if(Input.GetKey(KeyCode.S))
{
rigidbody2D.AddForce(-(transform.up) * power);
}
if(Input.GetKey(KeyCode.A))
{
transform.Rotate(Vector3.forward * turnpower);
}
if(Input.GetKey(KeyCode.D))
{
transform.Rotate(Vector3.forward * -turnpower);
}
}
//function OnGUI() //{
//}
I haven't done any 2D work but since you mentioned the Unity demo, can you look at its code and adapt it?
@getyour411 The demo uses Unity's build-in 3d physics system. The question asks about using 2d physics, meaning a lot of the effects of collisions need to be faked for the wheels.
There are some great articles on implementing 2d physics. There are also a couple duplicate questions.
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to add drift to top down car mechanics? 0 Answers
Car Model wheels problem 0 Answers
Any idea how to make an anti-lock braking system a.k.a. ABS? 1 Answer
How to make top down car movement? 1 Answer