Animation Events question: calling a function on a child object.

Hi, Im trying to setup an animation event so that when my character is halfway through the attack animation he will call the “attackEnemy” function.

This should be fairly straight forward but Im running into a little problem:
The “attackEnemy” function is not on a script that’s on the character itself, it’s on and empty Object which is a child of this character, therefore I cannot access it from the Animation Editor.

Any ideas on how I can get around this?

If I manage to get this working I’ll be able to get around a ton of hard coded values which will drastically improve my project.

Use the function: Unity - Scripting API: Component.GetComponentsInChildren Where the generic parameter T is your Script class type and then call the function.

Or you could loop through all children calling SendMessage.

I prefer that my parent object instantiate all its children and save a reference to them so I can call the function directly instead of using the methods mentioned above which relies on reflection.