input axis problem

Hi guys

when using input.GetAxis, how do I actually distinct between “s” and “w” keys? I basically want to say if the user press “s”, do something (accelerate) else if the user press “w” do something else (break).

Thanks

tiaan

Have a look at the documentation. Input.GetButton or Input.GetButtonDown are candidates.

And please check “project settings>input” section area. in default s and w secondaries of up arrow and down arrow. you might want change them too.

Let’s see if someone discover the problem before I unistall and reinstall the whole world. Coming back from holydays, my vertical axe doesn’t work anymore. Unity still detect “S” key pressure, but no “W”. The key works perfectly in all the other apps (I’m writing these wwwwwww now correctly in Safari) and even in the Unity editor. If I change the input key to something else, everything works. Build app shows the same problem. Maybe there are some hidden prefs that I messed up?

J.

that’s weird… having tried a new project? On a different project?

Perhaps try reinstalling Unity?

if(Input.GetAxis("Vertical") > 0.0)){
    //do stuff for the positive key here
}
else if(Input.GetAxis("Vertical") < 0.0)){
    //do stuff for the negative key here
}

I use this all the time, and it works a treat.