Question by
nreed132 · Apr 25, 2020 at 02:34 AM ·
scripting beginnerfunctioninteraction
How to call a function from a script to a specific object when there are multiple of said object on the screen
I have a few generators on screen at once, all containing the GeneratorController.cs script. I have the gameobject reference to the specific generator I want to access the script on stored in another script, but I don't know how to access the script from another script. Every other answer I've seen has had something that just references the script in its entirety, which wouldn't work since it would activate all of the generators rather than the one I want to. How can I access the function off of the specific gameobject I want it to run on?
I already have a ray that hits the object I need, if there's any way to use that.
Comment
Something like send$$anonymous$$essage, but only to a specific gameobject.