Sprint using transform.Translate?

Currently I have the following line for player movement:

transform.Translate (Input.GetAxis ("Horizontal") * Time.deltaTime * walkSpeed, 0f, Input.GetAxis ("Vertical") * Time.deltaTime * walkSpeed);

It sits in the “FixedUpdate” method, and “walkSpeed” is a float.

What I want, is for the character to move faster if you hold down the shift key (already have a runSpeed float variable declared).

And I’m having some trouble visualizing how this would be constructed in terms of logic. Like how could I maybe change the “walkSpeed” from that line, into “runSpeed” if the shift key is held down, or just call the same line, but with “runSpeed” and disable the previous line.

So far I tried doing if/else, where “if” the shift key is held down, the line has “runSpeed” in it, and “else” it isn’t, then the same line runs, but with “walkSpeed” instead. However, this causes the player to not move at all.

Instantly figured out the problem. My if/else solution was correct, I just had to write “Input.GetKey (KeyCode.LeftShift))” instead of “Input.GetKey (“Shift”))” in the if statement.

I should really experiment more before posting threads. I feel so dumb.