{

    public float walkspeed = 5f;
    Vector2 moveInput;
    public float jumpImpulse = 7f;

    private bool _isMoving = false;

    TouchingDirection touchingDirection;


    public float CurrentMoveSpeed { get
        
        {
            if (_isMoving && !touchingDirection.isOnWall)
            {

                return walkspeed;
            }

            else
            {
                return 0;
            }
        }
            
            
            
            
            }

    

    public bool isMoving 
    
    { get 
         
        
        {
           
            return _isMoving; 
        } 
        
        private set
        
        {
            _isMoving = value;
            animator.SetBool(AnimationStrings.isMoving, value);
        } 
    }


    public bool _isFacingRight = true;
    public bool isFacingRight { get { return  _isFacingRight; } private set {
        if (_isFacingRight != value)
            {
                //make the local scale to make the face the directions
                transform.localScale *= new Vector2(-1, 1);
            }
        
            _isFacingRight= value;
        
        } }

    Rigidbody2D rb;

    Animator animator;

    private void Awake()
    {
        rb = GetComponent<Rigidbody2D>();
        animator = GetComponent<Animator>();
        touchingDirection = GetComponent<TouchingDirection>();
    }

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void FixedUpdate()
    {
        rb.velocity = new Vector2(moveInput.x * walkspeed, rb.velocity.y);
        animator.SetFloat(AnimationStrings.yVelocity, rb.velocity.y);

    }

    public void OnMove(InputAction.CallbackContext context)
    {
        moveInput = context.ReadValue<Vector2>();

        isMoving = moveInput != Vector2.zero;
        SetFacingDirection(moveInput);
    }

    private void SetFacingDirection(Vector2 moveInput)
    {
        if (moveInput.x > 0 && ! isFacingRight)
        {
            //face the right
            isFacingRight = true;
        }

        else if (moveInput.x < 0 && isFacingRight)
        {
            //face left
            isFacingRight = false;
        }
    }

    public void OnJump(InputAction.CallbackContext context)
    {
        if ( context.started && touchingDirection.isGrounded)
        {
            animator.SetTrigger(AnimationStrings.jump);
            rb.velocity = new Vector2(rb.velocity.x, jumpImpulse);
        }
    }

}