- Home /
call a function of another object
I need help with this problem.
I have an object that is cloned 2 times, and an object that manages the mouse, I need that when the object that manages the mouse, press click on one of these 3 objects then send a message to the method of that object by giving the order to jump sit or stand still.
How do I send a message from script to script an object from another object to perform an action?
attached a sample image
necesito ayuda con este problema. tengo un objeto que es clonado 2 veces, y un objeto que administra el ratn, necesito que cuando el objeto que administra el ratn, presione clic sobre uno de estos 3 objetos entonces se enve un mensaje al mtodo de ese objeto dando la orden de saltar sentarse o quedarse quieto. como le envo un mensaje del script de un objeto al script de otro objeto para que realice una accin? adjunto una imagen de ejemplo
Answer by Justin Warner · Jan 07, 2011 at 04:03 PM
I need help with this problem.
I have an object that is cloned 2 times, and an object that manages the mouse, I need that when the object that manages the mouse, press click on one of these 3 objects then send a message to the method of that object by giving the order to jump sit or stand still.
How do I send a message from script to script an object from another object to perform an action?
attached a sample image
Eso podra ayudarle. Traducido para otros y ayudar, porque mi respuesta no es el lamento mejor y ms eficiente.
http://unity3d.com/support/documentation/ScriptReference/Component.BroadcastMessage.html
That might help you. Translated for others to help, because my answer isn't the best and most efficient, sorry.
LOL, I failed every spanish class except spanish 1... I used Google translate XD. It works amazingly... surprisingly. Haha.
thanks, I had an error with the name of the object that the broadcast did not work or sendmessage.
Well, i also use google translate for all my german assignments. :P it works though :)
Answer by montblack · Jan 07, 2011 at 06:31 PM
BroadcastMessage not work, that calls a function within the same object or the object is a child but I need to call a function of another object.
Why? I need to select an object and give the order to move to a point that I select with the mouse, then I need from the object "MAIN"which has the script "CURSOR"send a message with the click position the objects that I have selected.
i try with:
GameObject go = GameObject.Find("montblack"); go.Send$$anonymous$$essage("cambiar",1);
and doesn't work
"Send$$anonymous$$essage cambiar has no receiver!"