Play native animation clip when public static int condition is reached.

Im developing an AR application in Unity 4.6 using a public static int “nextNum” to que various text objects and animation clips. The animation clips were made using Unity’s built animation function, rather than imported from elsewhere, so should have no problem with being legacy etc. The public static int nextNum works fine and have it working with text, however I cannot que animations clips using a similar script.

The script below is attached to the model object, on which there is a number of animation clips. The animation clip CubeRise has been dragged/dropped into the inspector.

using UnityEngine;
using System.Collections;

public class CubeRiseControl : MonoBehaviour
{	
	public AnimationClip CubeRise;

	void PlayCubeRise ()
	{
		if (SetButInc.nextNum == 2)
		{
			animation.Play("CubeRise");
		}
	}
}

You need to attach an Animation component to your model and add your animation clips to the Animations array from that Animation component.

Then you can call your specific animation clip using:

using UnityEngine;
using System.Collections;
 
public class CubeRiseControl : MonoBehaviour
{   
 
    void PlayCubeRise ()
    {
        if (SetButInc.nextNum == 2)
        {
            // CubeRise is the name of the animation clip here that is added to the Animation component of model
            animation.Play("CubeRise");
        }
    }
}