Animate my child only?

Hello! :)

I have a scene with multiple instances of a gameobject is it possible to script:

If this gameObject plays animation idle > play this game objects child animation idle

I tried find but that gives me all the instances children :(

function Update () {

if animation.Play == (idle)
var child = transform.Find("sootje"); 
child.animation.Play(idle);

if animation.Play == (walk)
var child = transform.Find("sootje"); 
child.animation.Play(walk);

if animation.Play == (jump)
var child = transform.Find("sootje"); 
child.animation.Play(jump);

}

You're using the wrong function to see if an animation is playing. Honestly I don't know why that even compiles, other than some weird javascript reason that a string can evaluate to a bool..

Here's the documentation for animation.Play http://unity3d.com/support/documentation/ScriptReference/Animation.Play.html

What you want to use is animation.IsPlaying( animationName ), documentation here: http://unity3d.com/support/documentation/ScriptReference/Animation.IsPlaying.html

You also probably don't want to be checking it every frame without seeing if the animation is already being played, otherwise it will restart every frame and look wrong.

So try something like this.

void Update()
{
   if( animation.IsPlaying( "idle" ) )
   {
      if( !child.animation.IsPlaying( "idle" ) )
      {
          child.animation.Play( "idle" );
      }
   }
}

function Update () {

var child = transform.Find("sootje"); 

    if (animation.Play == ("idle"))
    child.animation.Play("idle");

    if (animation.Play == ("walk"))
    child.animation.Play("walk");

    if (animation.Play == ("jump"))
    child.animation.Play("jump");

}

this is what I have now, the child is not responding :(