.NET Fiddle

CSharp · Console

/Program.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{
    private enum PlayerState
    {
        Idle,
        Walking
    }

    private PlayerState _currentState = PlayerState.Idle;
    private Animator _animator;
    private Vector2 _movementInputVector;

    private void Awake()
    {
        _animator = GetComponent<Animator>();
    }

    void Update()
    {
        switch (_currentState)
        {
            case PlayerState.Idle:
                if (_movementInputVector != Vector2.zero)
                {
                    _animator.CrossFadeInFixedTime("Walk", 0.2f);
                    _currentState = PlayerState.Walking;
                }
                break;
            case PlayerState.Walking:
                if (_movementInputVector == Vector2.zero)
                {
                    _animator.CrossFadeInFixedTime("Idle", 0.2f);
                    _currentState = PlayerState.Idle;
                }
                break;
        }
    }

    public void OnMove(InputValue inputValue)
    {
        _movementInputVector = inputValue.Get<Vector2>();
    }
}
;