I have the following code:
if(Input.GetMouseButtonDown(0))
{
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray,hit,100.0))
{
//call the object's clickedOn() function
}
}
How do I call the object that was clicked on’s “clickedOn()” function, in my simple game every object has this function and each objects does something slightly different.