Created
June 17, 2021 16:22
-
-
Save qqpann/090fb90e0585a381b8dcb8c47915b0fd to your computer and use it in GitHub Desktop.
Cast ray to mouse pointer and detect the clicked position
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Clicked() | |
{ | |
var ray = Camera.main.ScreenPointToRay(Input.mousePosition); | |
if (Physics.Raycast(ray, out RaycastHit hit)) | |
{ | |
destination = hit.point; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment