Hello everyone! And thank you for reading this. So my problem is hopefully simple. I have come up with a basic movement system for a ship. When I press up it goes forward, when I press left and right it changes its rotation. My only problem is down. When I press down I want the ship to stop, but I don’t know how to do that. For now I set it to go backwards. Here is my code if you can help it would be very much appreciated.
using UnityEngine;
using System.Collections;
public class move : MonoBehaviour {
public float speed;
public float rotationSpeed;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (Input.GetKey ("right"))
{
transform.Rotate(Vector3.back * rotationSpeed, rotationSpeed * Time.deltaTime);
}
if (Input.GetKey ("left"))
{
transform.Rotate(Vector3.forward * rotationSpeed, rotationSpeed * Time.deltaTime);
}
if (Input.GetKey ("up"))
{
rigidbody2D.AddForce(transform.up * speed);
}
if (Input.GetKey ("down"))
{
rigidbody2D.AddForce(transform.up * -speed);
}
}
}