Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to set an if (Input.GetAxis ("Vertical")){ script?

Discussion in 'Scripting' started by JDVDeisgn, Mar 4, 2016.

  1. JDVDeisgn

    JDVDeisgn

    Joined:
    Oct 17, 2015
    Posts:
    148
    Not letting me do that. Presuming I'm going to have to declare a value as well or something
     
  2. Magison

    Magison

    Joined:
    Mar 1, 2013
    Posts:
    21
    Hello,
    have you read the Unity Documentation about Input.GetAxis?
    There is an example of keyboard/joystick input.
    http://docs.unity3d.com/ScriptReference/Input.GetAxis.html

    You declare a float variable for each axis and store the result of Input.GetAxis(...) in it.
    Then you can use this value for calculations.
     
    Pseudocivvy likes this.
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,557
    If you're not adding some useful information to a super old thread (6 years old), you're just necroing it and causing noise for others so please use the like button instead to show your appreciation of the help.

    Thanks.