I’m trying to make a GameObject follow the movement of the mouse.
I’m using “iTween.MoveToUpdate”.
But I’m confused on how to get the coordinates right. I’ve used the coordinates of the mouse but the result is not satisfactory. I’ve also tried to subtract the previous mouse coordinates by the new one and add the result to the the last know position of the GameObject and also played with the time. But the movement isn’t accurately following the mouse.
So my question would be;
How to I get the appropriate coordinates?
Where’s the best place to put this (Update, lastUpdate or OnMouseDown)?
You will want to use moveToUpdate in the Update function and I think the issue you are having is the difference between screen space and world space. Take a look into the documentatino for ScreenToWorld which is a method of Camera to help you out with the position values you will need to use with iTween for this: Unity - Scripting API: Camera.ScreenToWorldPoint