How to combine movements of the transform.rotation and transform.position

So, I’m wondering what to do for a code like this in C#:

using System.Collections;

public class Movement : MonoBehaviour {
	public float speed = 0.45f;
	public float turnSpeed = 20f;

	// Update is called once per frame
	void Update () {
		if (Input.GetKey(KeyCode.UpArrow)){
			animation.CrossFade ("Walk");
			transform.position += transform.forward * speed;
		}
		
		else if (Input.GetKey(KeyCode.RightArrow)){
			animation.CrossFade ("Walk");
			transform.Rotate(Vector3.up * turnSpeed);
		}
		
		else if (Input.GetKey(KeyCode.LeftArrow)){
			animation.CrossFade ("Walk");
			transform.Rotate(Vector3.down * turnSpeed);
		}
		
		else{
			animation.CrossFade("Idle");
		}
	
	}
}

So what do I do if I want to combine the movements of the rotations and the forward transform.position? For example, when I press the up arrow, the character walks forward, and when I press one of the right/left arrows the character turns around, however if I press the up arrow and the left/right arrows at the same time, only one happens (it either turns in place or walks forward)

So my question is, how do I code it so the character can walk forward while turning, and later walk backwards while turning, doing both at the same time without having to continuously just press the side arrows and the up arrows separately? This is so I can have smoother controls, obviously.

Thanks for reading!

Uhm, just remove the “else” from your if statements so each if statement is checked regardless of the one before. However you have to handle your pure else differently:

void Update()
{
    bool moving = false;
    if (Input.GetKey(KeyCode.UpArrow)){
        moving = true;
        animation.CrossFade ("Walk");
        transform.position += transform.forward * speed;
    }
    if (Input.GetKey(KeyCode.RightArrow)){
        moving = true;
        animation.CrossFade ("Walk");
        transform.Rotate(Vector3.up * turnSpeed);
    }
    if (Input.GetKey(KeyCode.LeftArrow)){
        moving = true;
        animation.CrossFade ("Walk");
        transform.Rotate(Vector3.down * turnSpeed);
    }
    
    if (!moving)
    {
        animation.CrossFade("Idle");
    }
}