I am new to using raycast, but I have learned to use a script I found on the Scripting API, to detect the collision of a raycast with another object. Is there any way that you can have an object detect that it has been hit by a raycast.
Thank you in advance for your reply
As far as I know, there isn’t any native callback doing. But nothing is keeping you to do your own.When you cast a ray, you probably already know that you can access the hit object with a RaycastHit variable. Then, just send a message to that object, like that :
//if( Raycast and stuff )
hit.collider.SendMessage( “OnRaycastHit” ); // Or any other name you like