I want to access the information from a Game Object’s Animator from a script attached to a different Game Object. How do I do this in C#? Thanks.
Figured it out. I added the GetComponent to the code that checks for collision:
void OnCollisionEnter2D(Collision2D target)
{
Animator animator = target.gameObject.GetComponent();
if (target.gameObject.tag == “Player”)
{
animator.SetBool (“Hit”, true);
}
Destroy (gameObject);
}