Answer the question
In order to leave comments, you need to log in
How to implement the code?
I have different scripts on different objects, but they have the same Action method (implemented differently in different scripts, just the same name). I want to cast a ray on an object through Raycast and call its Action method. But then I need to know the name of the particular script. What should I do?
Answer the question
In order to leave comments, you need to log in
Read about interfaces in c#. Here they are exactly for this.
And yes, GetComponent works with interfaces.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question