Hey guys, when my game starts my character flies away and I cannot figure what is wrong with this script :
#pragma strict
var walkspeed: float = 10.0;
var F = false;
function Jump()
{ if (F == false);
F = true;
animation.Play("Damage"); rigidbody.AddForce(Vector3.up *15);
yield WaitForSeconds(0.8);
animation.Stop("Damage");
animation.Play("Wait");
yield WaitForSeconds(3);
F = false;
}
function Move()
{ animation.Stop("Wait");
animation.Stop("Damage");
animation.Play("CharWalk");
}
function StoppedMove()
{ animation.Play("Wait");
animation.Stop("Damage");
animation.Stop("CharWalk");
}
function Start() {
}
function Update() {
rigidbody.freezeRotation = true;
if (Input.GetKey(KeyCode.W)) transform.Translate(Vector3(0, 0, 1) * Time.deltaTime * walkspeed);Move();
if (Input.GetKeyUp(KeyCode.W));
StoppedMove();
if (Input.GetKey(KeyCode.S)) transform.Translate(Vector3(0, 0, - 1) * Time.deltaTime * walkspeed);
if (Input.GetKey(KeyCode.A)) transform.Translate(Vector3(-1, 0, 0) * Time.deltaTime * walkspeed);
if (Input.GetKey(KeyCode.D)) transform.Translate(Vector3(1, 0, 0) * Time.deltaTime * walkspeed);
if (Input.GetKeyDown(KeyCode.Space) && F == false);
Jump();
}