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.

Question Animation in new Input System

Discussion in 'Input System' started by bratan20000, Feb 13, 2022.

  1. bratan20000

    bratan20000

    Joined:
    Oct 28, 2021
    Posts:
    12
    Hi, guys!
    I have Input System with Action Moving and inside it have Vector2D Composite, with up - W; down - S; left - A;
    right - D.
    How to do when i for example press D animation would be for right and so on?
    Using comparing, for instance, if (_movingDirection == Vector2.right) { _animator.Play(_animationName)}
    isn't so good, i think. Maybe there are some more methods how to do it?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,325
    Don't conflate systems.

    New input system (or old input system) has absolutely nothing to do with animations.

    An input system reads inputs and gives values back.

    That's it.

    You should store those values to temporary variables.

    Then your code should act on those stored temporary values each frame.

    Some of your actions might include:

    - moving the player
    - animating the player
    - playing sounds
    - firing weapons.
    etc

    Note how NONE of the ultimate uses of the input data have anything to do with where the input came from.
     
    bratan20000 likes this.
  3. bratan20000

    bratan20000

    Joined:
    Oct 28, 2021
    Posts:
    12
    Ok, thanks!