How can I change player sprite based on mouse position relative to the player?

So, I have 2d scene and want player to switch between idle sprites based on where he’s looking (i.e. where is mouse cursor relative to player).
I set up an “Idle” blend tree, which switches idle state sprites for 8 directions with parameters “Mouse Horizontal” and “Mouse Vertical”.
Howewer, blend tree reads mouse coordinates only when I move the mouse. When I move mouse to the left it switches to “look_left” sprite, even if mouse is to the right of the player. When I’m not moving mouse it just uses first sprite in blend tree.

How can I find mouse position relative to the player and use it to swich sprites?

Here is the code i used:

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

public class PlayerMovement : MonoBehaviour
    public float moveSpeed = 5f;
    public Rigidbody2D rb;
    public Camera cam;
    public Animator animator;
    Vector2 movement;
    Vector2 mousePos;

    void Update()
        movement.x = Input.GetAxisRaw("Horizontal");
        movement.y = Input.GetAxisRaw("Vertical");
        mousePos.x = Input.GetAxisRaw("Mouse X");
        mousePos.y = Input.GetAxisRaw("Mouse Y");

        animator.SetFloat("Mouse Horizontal", mousePos.x);
        animator.SetFloat("Mouse Vertical", mousePos.y);
        animator.SetFloat("Move Horizontal", movement.x);
        animator.SetFloat("Move Vertical", movement.y);
        animator.SetFloat("Speed", movement.sqrMagnitude);

    void FixedUpdate()
        rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);

You must compare the mouse position given by Camera.main.ScreenToWorldPoint(Input.mousePosition) to the player’s position given by rb.position.

By comparing the individual x,y coordinates obtained from these functions you will know if the mouse is to the left of the player (mouse.x < player.x), above the player (mouse.y > player.y), etc.

try to use “Camera.main.ScreenToWorldPoint(Input.mousePosition);” than just the last movement of the mouse