Get accurate mouse position

I am trying to make a game where a cursor will be at the mouse cursor position if it is near enough to the player. When I use Input.mousePosition, it teleports my cursor sprite above and to the right of my mouse cursor. Is there a way to get the exact point where the tip of my mouse cursor is?

Here is my code :



Thanks for your help!

Input mouseposition is exacting. Maybe your cursor sprite has its pivot on the corner?

You can get your mouse position in the screen using this and update your sprite position using this vector

Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Vector3 pos = ray.origin + (ray.direction);  

You can replace pos.z = 0 juste to have the position in the sceen if needed

Hope it helps