GetKey does not work correctly

Hi,

I have an odd Problem:

In my script I use Input.GetAxis(“vertical”) and Input.GetAxis(“horizontal”) to set a direction. I also ask for Input.GetKey(“space”) to toggle running. And it works! EXCEPT when going left-upwards. When I have the up key and the left key pressed at the same time the Input.GetKey command won’t work. But since it works perfectly for all other directions I have no clue why this is!

Any ideas?

function Update () {
	
	Direction = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
	
	if (Input.GetKey("space")) {
		moveSpeed = moveSpeedRun;
	} else {
		moveSpeed = moveSpeedDefault;
	}

	if (rigidbody.velocity.magnitude < moveSpeed) {
		rigidbody.AddForce(Direction*Time.deltaTime*100, ForceMode.VelocityChange);	
	}
}

I’m sure GetKey works correctly, you’re just not using it correctly.

You’re probably looking for: