play animation on other object

Hello,

I’ve got this code:

if(Input.GetMouseButton(0)) { animation.Play("attack"); }

But now it wants to play the “attack” animation on the watermark, and not on the game object I want.
I get this error: MissingComponentException: There is no ‘Animation’ attached to the “UnityWatermark-small” game object, but a script is trying to access it.
You probably need to add a Animation to the game object “UnityWatermark-small”. Or your script needs to check if the component is attached before using it.

So when I hit the watermark GUI, it must play the attack animation on a other game object.
Oh and by the way I think it must be something like if(Input.GetTouch) because it’s for android.
Who can help me with this? Thanks!:wink:

If your input script that is attached to a button or in this case a GUITexture, has/uses the animation function without specifying the game object it will automagically try and do it on the game object the script is attached to.

You can either, create a reference variable to your game object(setting it on Start or throught he inspector if it isn’t dynamic or sent messages to the game objects among other things.