Playing animation via script - any ideas

Hi -

Can anyone tell me why the following script doesn’t play animation?

class AnimationPlayer
{
public AnimationClip ClipToPlay = null;
private GameObject goAnimationPlayer = null;
private string sClip = null;

public void Awake
{
  if (this.ClipToPlay != null)
  { 
      this.goAnimationPlayer = new GameObject();
      this.goAnimationPlayer.AddComponent(typeof(Animation));                this.goAnimationPlayer.animation.AddClip(this.ClipToPlay,this.sClip);
  }
}

public void OnTriggerEnter(Collider prCollider)
{
  if (this.ClipToPlay != null)
  {
    this.goAnimationPlayer.animation[this.sClip].wrapMode = WrapMode.Once;   
    this.goAnimationPlayer.animation.Play(this.sClip)
  }
}
}

What I want to know if this is possible. I’m not worried about the merits to if this is the best approach for doing something in Unity.

Thanks -

what does the code should do exactly? :?
Do you want to play an animation when the player enters a trigger?
(use the “trigger” code and set it to “animate”, then deactivate the objects “play automaticly” and set “wrap mode” to “once”)