so I’m trying to create a script to make a GameObject follow the mouse when pressed.
I’ve tried to work with the functions MouseDown and MouseDragged.
I’m having alot of problems and I think I got it all wrong.
what are the variables that refers to the X and Y coordinates of the mouse? and is there any built-in script for the thing I want? it’s really strange for me that I’m not able to find one, this should be a basic thing.
You need to convert screen points, which is what the mouse uses, to world points, which is what the game object is using. You can do this by using Camera.ScreenToWorldPoint().
So in the MouseDrag event, you would do something like this: