So I am making movement in my game that replicates the movement in Asteroids. I can get it to work with a 3D rigid body using (camera looking top down):
public float thrust = 100.0f;
public float rotate_speed = 60.0f;
if (Input.GetKey(KeyCode.UpArrow)){
rigidbody.AddForce(transform.forward * thrust * Time.deltaTime);
}
if (Input.GetKey(KeyCode.LeftArrow)){
transform.Rotate(0.0f,-rotate_speed * Time.deltaTime,0.0f);
}
if (Input.GetKey(KeyCode.RightArrow)){
transform.Rotate(0.0f,rotate_speed * Time.deltaTime,0.0f);
}
If I try and replace most of this with “2D” code on a sprite and a rigidbody2D, I can’t figure out the solution. I guess my main problem is how to “AddForce” “forward” in 2D. Thanks.