Object around the target that follows the mouse cursor

Hi, i’m triyng to make an mmorpg game.
I need a way to rotate an object around a point, that follow the mouse cursor position.
I will post a gif that can help you to understand.

This is the script that I made but is not working because the object rotates around the the target constantly.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class CursorMovement : MonoBehaviour
{
    public Transform target;
    public Camera cam;
    public Vector2 mousePos;

    // Update is called once per frame
    void Update()
    {
        mousePos = cam.ScreenToWorldPoint(Mouse.current.position.ReadValue());
        float angle = Mathf.Atan2(mousePos.y, mousePos.x) * Mathf.Rad2Deg;
        transform.RotateAround(target.position, new Vector3(0f, 0f, 1f), angle);
    }
}

6916169--811175--final_6046881c4541e8006b0ea0c7_266467.gif

As described in the documentation, RotateAround rotates around the target, on the defined axis, BY the given angle. Unity - Scripting API: Transform.RotateAround
So as long as angle is not 0, it will rotate.

Instead just calculate the vector from your object to the mouse pointer, normalize it and place the ball at some predefined distance away from the starting object. There, it will now always be between the object and the mouse, at the same distance away from the object. Which is what you want.

Let me quickly add that coop or multiplayer games are absolutely not recommended for beginners. Let alone MMORPGs. Not trying to be offensive, but if you are stuck on problems like this, how are you gonna handle all the networking or threading stuff involved in the creation of an mmorpg? Id highly recommend getting some more experience with smaller singleplayer game projects before tackling such a large project. That way youd know your way around the Unity Engine and would be able to focus on new topics like networking or parallelization.