Skip to content

Instantly share code, notes, and snippets.

@nopitech
Created May 7, 2019 13:32
Show Gist options
  • Save nopitech/167d1083c593b9d80a24ee813de145cc to your computer and use it in GitHub Desktop.
Save nopitech/167d1083c593b9d80a24ee813de145cc to your computer and use it in GitHub Desktop.
void Update()
{
// クリックした位置へのレイ取得
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
// クリックしたら
if (Input.GetMouseButtonDown(0))
{
// レイ飛ばす
if (Physics.Raycast(ray, out hit, 100f))
{
Debug.Log(hit.collider.name);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment