Ive really been pulling my hair out over this one! All i have is a handle which should allow the user to click on then drag up and down, then when released will go back to the default position.
Right now i can click on the handle, then when i move the mouse below this initial point the handle rotates down and vice versa. However how can i have the handle ‘follow’ the mouse position? So that the handle isn’t either ON or OFF, it can be controlled precisely with the mouse?
make and empty object, and place your handle as a child of that object. make sure ur handle is set to start in the midle of the empty object. then rotate the empty object on the x or z axis. the center of the empty object will act as a pivot for your handle.
so here’s the thing i came up with. you make a invisible plane, then u cast a ray from the cam onto that plane (that plane has a collider), you take the impact point and u make the handle lookat that point.
Edit: the above does not work, but i found a solution, all you have to do is add this line: hit.point.x = 0; after this oneDebug.DrawLine (ray.origin, hit.point); in the file mouseclick.js i gave u in the attachement.