simple question about ray casting:
Does Unity provides a function similar to
OnTriggerEnter() that is automatically fired every time an object was hit by a Raycast?
Let me clarify the problem:
I have two scripts. The first one is attached to the PlayerController camera (which fires a Raycast on the Update method), the second one called KeyObjectController is attached to every GameObject in the scene that is marked as a key object.
Now, from this script, I’d like to create a Lerp animation on the material to create a sort of highlight effect, only when the object is hit by the player camera Raycast.
I know I could check the hit game object tag directly form the player script, and call the
sendMessage method to invoke the Highlight function, but I’d like to keep the logic directly into the KeyObjectController script.
Is that possible?
Thank you guys.