Last active
January 3, 2021 18:11
-
-
Save quakeboy/b4015d9b72ef1053d913 to your computer and use it in GitHub Desktop.
Unity3d mouse hit test with any 3d box collider
This file contains 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 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"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Its working Thank you ❤️❤️ its big help!