I have a flying plane(sprite) that has a box collider2d, controller script(named Pilot), and a rigidbody2d
The plane has an empty GameObject as a child called point.
this is my Pilot script(JS):
#pragma strict
var point : GameObject; //child object point(Defined in inspector)
function Start () {
}
function FixedUpdate () {
if (Input.GetKey(KeyCode.Space)) {
var direction : Vector3 = point.transform.position - transform.position;
rigidbody2D.AddForce(direction * 10000);
}
if (Input.GetKey(KeyCode.S)) {
rigidbody2D.AddTorque(30);
}
if (Input.GetKey(KeyCode.W)) {
rigidbody2D.AddTorque(-30);
}
}
The problem is that the plane stops instantly when I release the space bar. The rotation works just fine. A cube with a 2D box collider and a rigidbody2d works perfectly but not my plane. I have also tested to change the FixedUpdate to Update but it doesn’t do anything I think.
All help is appreciated!
