Skip to content

Instantly share code, notes, and snippets.

@quakeboy
Last active January 3, 2021 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quakeboy/b4015d9b72ef1053d913 to your computer and use it in GitHub Desktop.
Save quakeboy/b4015d9b72ef1053d913 to your computer and use it in GitHub Desktop.
Unity3d mouse hit test with any 3d box collider
void Update ()
{
if ( Input.GetMouseButtonDown(0) )
{
Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit myHitInfo = new RaycastHit();
if ( GetComponent<BoxCollider>().Raycast(inputRay, out myHitInfo, 10000f ) )
Debug.Log("Clicked");
}
}
@FrojeloxD
Copy link

Its working Thank you ❤️❤️ its big help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment