I have a strange problem. I want to trigger animation on bunch of newly instantiated prefabs. If I trigger animation right after creating objects, nothing happens, no animation is played. If I hold it off until next call of update() , it works fine. Any tip what might be a problem?
The function in which I’m triggering animation looks like this:
protected void StartTileInitialAnimation() {
Vector3 bottomLeftCoords = levelManager.GetBottomLeftTileCoords();
foreach (GameObject tile in levelManager.currentLevelTiles) {
Vector3 diff = tile.transform.position - bottomLeftCoords;
float distance = Mathf.Abs(diff.x) + Mathf.Abs(diff.y);
float maxDistance = 14f;
Animator animator = tile.GetComponent<Animator>();
animator.enabled = true;
animator.Play("TileAppear", -1, distance / maxDistance);
animator.SetBool(Animator.StringToHash("shake"), true);
}
}