Code Example on Solving this with operators in if and using Methods

Hello heres a Code Example that doesnt prioiritize keys
|| => boolean OR
& => boolean AND

And some handling Code with Methods

void Update () {
this.processInput();
}

private void processInput()
{
    if (Input.GetKey(KeyCode.Space))
    {
		print("Space pressed  ## Move UP");
		
    }
		rotateLeft();
		rotateRight();
}
private void rotateLeft()
{
	if (Input.GetKey(KeyCode.A) & !Input.GetKey(KeyCode.D)|| Input.GetKey(KeyCode.A) & !Input.GetKey(KeyCode.D)& Input.GetKey(KeyCode.Space))
	{
		print("A pressed ## rotate left");
	}
}
private void rotateRight()
{
	if (Input.GetKey(KeyCode.D) & !Input.GetKey(KeyCode.A)|| Input.GetKey(KeyCode.D) & !Input.GetKey(KeyCode.A) & Input.GetKey(KeyCode.Space))
	{
		print("D pressed ## rotate right");
	}
}
1 Like

Awesome job with your code!

1 Like

Privacy & Terms