Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question "New" Input System equivalent of Input.GetAxisRaw

Discussion in 'Input System' started by Fluffy_me, Nov 17, 2020.

  1. Fluffy_me

    Fluffy_me

    Joined:
    Nov 16, 2020
    Posts:
    8
    Hi there, im using the "new" input system for the first time now and im wondering if i can use an equivalent of the Input.GetAxisRaw("Horizontal") funcion. (I'm using it for my animator, so the idle faces the way of the last input).

    Should i just use the old Input System or is there any other way to get around this?
     
  2. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    JG0328, GameDev_Chuck and Fluffy_me like this.
  3. FileThirteen

    FileThirteen

    Joined:
    Oct 23, 2012
    Posts:
    40
    You can just read the value using context.ReadValue<float>() within your callback function for your input axis action, and you can take that value and normalize it and then cache it for use in your Update or FixedUpdate methods.

    Alternatively I created a paid asset that lets you use the new input system the same way you would code for the old input manager, so you can use the input action asset but write your code the old way. It has Input.GetAxisRaw and is very easy to use. You can literally use a script written for the old system, add the new Input System from the package manager and then install my asset and it will immediately start using the new Input System with no code changes. There is a link in my signature if you are interested.
     
    Fluffy_me likes this.
  4. Fluffy_me

    Fluffy_me

    Joined:
    Nov 16, 2020
    Posts:
    8
    Oh thanks, that worked for me :)