#Sprint script 2D

1 messages · Page 1 of 1 (latest)

terse bear
#

how do I make a code, when I press "Shift" my move speed increase?

terse bear
#

@trim storm I want to increase the speed only when i press the button

trim storm
#

Yes, you use that method to check if the button is pressed

#

You're already using a similar method, so you know how to check for input

terse bear
#

if (Input.GetKey(KeyCode.Q))
{
moveSpeed = 30f;
}

#

or

#

if (Input.GetKeyDown(KeyCode.Q))
{
moveSpeed = 30f;
}

#

It stays till the end

trim storm
#

That's not Shift is it

terse bear
#

no, but I dont know how to do it with shift

#

i always have error whenever there is shift or Shift

trim storm
#

Your code already responds to the Q key

#

Read the docs carefully, you can figure this out. The problem is you are rushing and guessing

vale bane
trim storm
#

If you need a hint: ||notice that the docs say the key can be identified by a value from the KeyCode enum. So... read the docs for KeyCode and see what key matches what you need||

terse bear
#

The point is that whenever i press(just press) the key, my speed value change till i stop my project

trim storm
#

That's because you're not resetting the speed if the key is not pressed

terse bear
#

ooh

#

ok

#

i have to do it with "else"?

trim storm
#

Bingo

terse bear
#

🥳

#

😐I dont know how

vale bane
terse bear
#

When i type else my character doesnt mogę

#

Move*

vale bane
terse bear
#

that is probably the stupidest code you ve ever seen, but I am dumb

#

😉

#

oh wait

#

nevermind

#

I restarted my computer and now its worng

#

working*

#

thx so much

trim storm
#

Excellent, glad you got it working