Aiming with controller joystick in top down shooter

I have this code attached to a crosshair gameobject that is parented to the player in a top-down shooter. It is supposed to control the crosshair position on screen when using the right controller joystick to aim, however the crosshair sprite that is attached to the crosshair gameobject is vibrating a lot. I don’t know how to go about fixing this.

public class Crosshair : MonoBehaviour
{
    private GameObject Player;

    Vector2 ToPos;

    public float RightHorizontalInput;
    public float RightVerticalInput;

    public float MaxDistance;

    void Start()
    {
        Player = GameObject.FindWithTag("Player");
    }

    void Update()
    {
        RightHorizontalInput = Input.GetAxisRaw("RightStickHorizontal");
        RightVerticalInput = Input.GetAxisRaw("RightStickVertical");

        ToPos = new Vector2(Player.transform.position.x + (RightHorizontalInput * 10), Player.transform.position.y + (RightVerticalInput * 10));

        transform.position = Vector2.MoveTowards(Player.transform.position, ToPos, MaxDistance);
    }
}

You need to multiply your last MoveTowards parameter by delta time to have it move smoothly.

I tried this but it only made the shaking worse:

transform.position = Vector2.MoveTowards(Player.transform.position, ToPos, MaxDistance * Time.deltaTime);

I think the shaking has to do with the axis input fluctuating a lot even if the joystick is held still.

It’s probably because your first parameter is the player’s position, not the crosshair’s position. Try:

transform.position = Vector2.MoveTowards(transform.position, ToPos, MaxDistance * Time.deltaTime);