Skip to content

Instantly share code, notes, and snippets.

@qqpann
Created June 17, 2021 16:22
Show Gist options
  • Save qqpann/090fb90e0585a381b8dcb8c47915b0fd to your computer and use it in GitHub Desktop.
Save qqpann/090fb90e0585a381b8dcb8c47915b0fd to your computer and use it in GitHub Desktop.
Cast ray to mouse pointer and detect the clicked position
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