Weird delay with Boost

Seem to be having a weird delay that I can’t figure out. After entering the code, and going in to Unity to test everything; the boost didn’t activate for a couple of seconds. After holding down the up arrow, just before the finish line; my snowboarder shot through. Boost only seems to happen after repeatedly tapping the up arrow, but so far have only been able to activate it twice.

Can you show the code where the boost is supposed to activate?

Hi Rinovdro,

Welcome to our community! :slight_smile:

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture? Maybe there is a typo somewhere in your script?


See also:

Yeah, I thought the same thing so I compared everything. Nothing was out of place that I could see, but I’m not perfect :stuck_out_tongue: The boost happens, but it’s just a really weird delay that I can’t figure out, almost 5seconds. Haven’t been able to activate it more than 3times since I posted this.

You are checking Input.GetKeyUp(KeyCode.UpArrow). This will only return true when you let go of the key i.e. the key is ‘up’. You should be checking Input.GetKey(KeyCode.UpArrow) which returns true in every frame that the key is pressed. With your code, the boost only happens when you let go of the up arrow

Funny how the silliest of mistakes can cause the biggest of issues lol
Weird, even holding it down didn’t do the boost O,o
But, I see your point lol it works now. Thanks! :slight_smile:

Holding it down don’t do the boost, because the boost is triggered when you let go of the button. For a single frame. That’s why repeatedly tapping the up arrow worked.

Input.GetKeyDown(...) returns true in the frame that you pressed a button. In the next frame it will return false, even if you are holding down the button.

Input.GetKeyUp(...) returns true in the frame that you released a button. In the next frame it will return false, as it should, because you are not pressing the button.

Input.GetKey(...) returns true in every frame that you are holding a button.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.