I have a script:
private var moveDirection : Vector3 = Vector3.zero;
var speed = 3;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
Screen.showCursor = false;
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
controller.Move (moveDirection * Time.deltaTime);
transform.Rotate(Vector3(0, Input.GetAxis("Mouse X"), 0) * Time.deltaTime * 50);
if (Input.GetKeyDown (KeyCode.LeftShift))
{
speed += 10;
}
if (Input.GetKeyUp (KeyCode.LeftShift))
{
speed -= 10;
}
}
How can I change the movement speed when I press W, A, S and D (It works for sprint but not if I do it for the other keys)