Receiving information about getting hit by a Raycast

Good morning, afternoon, evening . . . night!

This may well be quite an inexperienced and foolish question, so bear with me here.

Though I’m currently considering the possibility of messing about with raycasting. And therein lies my question. as though it’s possible to receive information about which objects the ray has undoubtedly collided with. Is it possible to receive information if your desired collider has been hit by a raycast?

Similar in sense that you can track/trigger generic collisions, is it possible to track raycast collisions outside of the script that initiated it?

There’s no standard feature for this functionality, but it is trivial for the Raycaster to inform a script on the object it hit that the hit occurred. It can be done using GetComponent() or SendMessage() in just a line of code or two assuming there is a script on the objects with the collider to ‘receive’ the information. In C# you could use Events and Delegates to inform any script that wanted to know what object(s) are hit.

Discovered/Designed a potential answer to my own mullings,

So here’s merely how I’ve chosen to undertake that particular issue (for anyone who may need it):

private DesiredScriptName  scriptCommunication; 
 

// =============================================== //
// Designates A Permanent Raycast That Will Determine Whether The Desired GameObject Has Been Collided With
// Allows Direct Communication With The Specific "Desired" GameObject That Was Interacted With

if (Physics.Raycast (transform.position, directionRay, out collisionRay, distanceRay) ) 
    {     
        if (collisionRay.collider.gameObject.tag == "Desired GameObject Tag" )
        {  
        scriptCommunication = destinationTransform.gameObject.GetComponent <Desired Script> ();
        scriptCommunication.designatedboolean = true; 
        }
    }