unity how to convert mouse screen position to world position
Camera.main.ScreenToWorldPoint(Input.mousePosition)
unity how to convert mouse screen position to world position
Camera.main.ScreenToWorldPoint(Input.mousePosition)
unity mouse position to world
Vector3 worldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
unity mouse world position
//check for Left mouse Key
if (Input.GetMouseButtonDown(0))
{
RaycastHit hit;
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100))
{
//hit.point is the position, where the Raycast from the camera
//position towards the ground hit the first collider
Vector3 positionInWorld = hit.point;
//Do something with positionInWorld here...
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us