I am creating a game in Unity 3d that is using an animation to move an object. For some reason the animation only works the first time it is accessed and from then on it acts as if it is not being called even though I have debugged and I see that it is being called. Here is the code I use to call the animation:
if (anim == null)
{
foreach (Transform component in myObject.transform)
{
anim = components.GetComponent<Animator>();
}
}
anim.Play("Flip-Forward");
anim.enabled = true;
As you can see I have an animator connected to myObject that I access in order to plan an animation. "Flip-Forward" is one of the animations I have created.