Hi all, I can’t seem to get this to work. I have a main script on an empty GameObject which is sending some values to another GameObject that has two scripts attached. All Javascripts.
First I do a GameObject.Find in the main script like this:
destination_object = GameObject.Find(“player_camera”);
Then I do a GetComponent in the main script like this:
destination_object_script = destination_object.GetComponent(“script_rotate”);
Both work fine.
In the main script, to send the data, I use
destination_object_script.SendMessage(“x_value”, x_value);
The thing is, I have two two scripts attached to the second GameObject—one named “script_rotate” and the other named “script_move”. They both have functions with the same name in them (i.e., “x_value” etc.). I did this so I could, in theory, specify the exact script to send the messages to (in one place) and they wouldn’t get sent to the other attached script—and thus save having to make different names for the functions etc. But they are getting sent to both scripts no matter what I do.
In the documentation under Component.SendMessage it says
Calls the method named methodName on every MonoBehaviour in this game object.
Is there something I’m missing to be able to select just ONE script attached to a GameObject and use SendMessage to its functions, without sending them to functions in other scripts attached to that object…even if the functions have the same name?
Pretty lost on this one. Thanks for any help!