I have a function that plays an animation. It is correctly setup up because when I call it from Start () function, it does play the animation. But, when I call it from another script, the animation simply does not play it.
var animator : Animator;
function Start () {
SwapColors2And5();
}
function Update () {
}
function SwapColors2And5 () {
Debug.Log("2 and 5 called");
animator.Play("colorSwap2And5");
}
This works. But when I try to call SwapColors2And5 from another script, the animator doesn’t play it, even though Debug is logging “2 and 5 called”.
Here’s my call from the other script:
var enemyScript = enemy.GetComponent(enemyController); //this is where I get the actual script
if (randomNumber % 2 == 0 && randomNumber % 3 == 0) {
enemyScript.SwapColors2And3();
}
The function is being called, Debug.Log works, but the animator.play does not.