I’m working on an asteroids style game, and I can’t figure out how to apply a forward velocity for the ship. So far I’ve done is a rotation but any form of forward thrust I can’t do.
This is my code so far:
public float speed = 10.0f;
public float rotationSpeed = 10.0f;
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.W))
{
//not working
rigidbody2D.AddForce(Vector2.up * speed);
}
float rotate = Input.GetAxis("Horizontal") * rotationSpeed;
transform.Rotate(0, 0, 0 - rotate);
}