Hello all,
Been working on this little project with a Rigidbody2D rocket, however, the flight of the rocket is not working quite how I would like it to. I would like the rocket to always move in the direction it is facing, like a jet. As it is now, it kind of Tokyo drifts round corners. This video maybe explains it better:
If anyone could shed some light on how to code this I would be most grateful!
Also see images for what I am trying to achieve.
Many thanks in advance!
public float velocity;
public float leftRotationSpeed;
public float rightRotationSpeed;
void FixedUpdate()
{
if (Input.GetKey (KeyCode.UpArrow))
{
GetComponent<Rigidbody2D>().AddForce(transform.up * velocity);
}
if (Input.GetKey (KeyCode.DownArrow))
{
GetComponent<Rigidbody2D>().AddForce(transform.up * -velocity);
}
if (Input.GetKey (KeyCode.LeftArrow))
{
GetComponent<Rigidbody2D>().AddTorque(Input.GetAxis ("Horizontal") * leftRotationSpeed);
}
if (Input.GetKey (KeyCode.RightArrow))
{
GetComponent<Rigidbody2D>().AddTorque(Input.GetAxis ("Horizontal") * rightRotationSpeed);
}
}
}