'Unity 2D: Add Animations to Instantiated child components/De-sync animation
I'm working on a project where I need to animate a group of butterflies, which exist as instantiated children components. I was able to add an animation to the parent components and have the child components inherit from that, but the issue is that the animations are synced. We're talking about ~100 instantiated objects, so I'm looking for an automated solution.
// Portion of Flock Agent Class
void Start()
{
offset = Random.Range(0, 8);
agentCollider = GetComponent<Collider2D>();
agentFieldOfView = GetComponent<AgentFieldOfView>();
//Animation
anim = GetComponentInParent<Animator>();
anim.SetFloat("Offset", offset);
}
This is what I have so far in my Flock Agent class, which gives me the following results. The picture shows 'Flock Orange: Sprite missing,' and the animations still synced. Current state
Thank you, Onion.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

