Cool Im going to dig into this now. Thanks!
(P.S. its not null after the first frame for sure)
It seems calling the animation on the same frame that I create the unit causes the issue. Very odd..
var unit= Instantiate(Resources.Load("Prefabs/unit", typeof(GameObject))) as GameObject;
unit.SendMessage("PlayIdle"); //causes error
However if I do this
var unit= Instantiate(Resources.Load("Prefabs/unit", typeof(GameObject))) as GameObject;
StartCoroutine("playIdle");
IEnumerator playIdle()
{
yield return new WaitForSeconds(1);
foreach(GameObject unit in units)
{
unit.SendMessage("PlayIdle");
}
}
I get no error.
Perhaps theres something funky going on under the hood.
Also Pharan I checked for any disabled scripts, everything is a go. I have a prefab premade on the scene and it DOESNT give the error. Its only the new units I spawn at runtime that give the error (and they are carbon copies of the one already in the scene which doesnt generate the error).