Hi everyone,
I am trying to make my first game, but I have some problems with the speed of my player.
When I just move my player everything goes fine but as soon as press space to jump my player goes super fast:cry:
Can anyone point out what is wrong in my script?
Thanks in advance !
#pragma strict
var moveSpeed = 350;
var jumpHeight = 8;
var isFalling = false;
function Update ()
{
//moving player;
var moveHorizontal : float = Input.GetAxis("Horizontal");
var moveVertical : float = Input.GetAxis("Vertical");
var movement : Vector3 = new Vector3 (moveHorizontal,0.0f,moveVertical);
rigidbody.AddForce(movement * moveSpeed * Time.deltaTime);
//letting player jump
if(Input.GetKeyDown(KeyCode.Space) isFalling == false)
{
rigidbody.velocity.y = jumpHeight;
}
isFalling = true;
}
function OnCollisionStay ()
{
isFalling = false;
}