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 -