Hi everyone, does Unity keep track of where the mouse pointer is? I want to use my mouse pointer’s transform position as the beginning point of a spherecast.But I’m not sure how.
if(Physics.SphereCast(//mousepointer.transform.position, 1f, gameObject.transform.forward, out hit, Distance))
Input.mousePosition
is what you are looking for but it will probably won’t do what you are expecting. The position is based on the screen position, so if your screen is 800*640 you won’t get anything bigger or smaller than that. Also, it returns a Vector3 which is indeed a Vector2 with a 0 for z → Vector3
You may want to look at Unity - Scripting API: Camera.ScreenToWorldPoint for how to convert the mouse position on screen to world position.