Having trouble with something very basic, Sprint function.

Hey there!, I’m trying to make a pretty basic 2D RPG style game, and having a bit of trouble right off the bat!

I’ve got a character controller that works, I can move around, what I’ve tried to do is add a Sprint function (Hold shift, you walk faster).

This is what I have, but pressing Shift does nothing, I’m sure it’s a super simple mistake somewhere that I just need someone to point out!.


Many thanks in advance!

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run?
  • what are the values of the variables involved? Are they initialized?

Knowing this information will help you reason about the behavior you are seeing.

Input.GetKeyDown is only true on the first frame that the key is pressed.

Input.GetKey is true for every frame during which the button is held down.

Sorry. It’s been a few years since I’ve been here, I’ll make use of Code tags from here on out.

I did end up sprinkling a few Debug.Logs around and saw it seemed to be working, I just didn’t understand the difference between GetKey and GetKeyDown.

Thanks for the help!

1 Like

That’s the ticket!, Many thanks.