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 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:
    38,520
    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!