system
1
Hi, this is weird question but can someone please explain ScreenToViewPoint to me?
function Update () {
transform.position = camera.main.ScreenToViewportPoint(Input.mousePosition);
}
If I want to make an object move to wherever the cursor goes, how would I do that using this script?
Mike_3
2
ScreenToViewportPoint maps 0->ScreenSize to 0->1 (basically divides x by Screen.width, y by Screen.height). It's almost certainly not what you need.
I would look into either ScreenToWorldPoint or Physics.Raycast, depending on whether your game is 2D or not
Cam_1
3
I suggest using Input.mousePosition and using that in conjunction with ScreenToWorldPoint, then transform the position.