I added animation events to my walking animations and I want the events (sound effects playing) to only work with the main character, NOT the enemies, even though they use the same animations.
Is there a way beside testing if
transform.root.name == "Hero"?
This would be quite heavy on performance because I have many enemies using the same animation.
You can do this by adding Audio Source component to your player only. And drag your sound effect into that Audio Source component. Then you can use player script for playing sound effect whenever you want to. But if this is not what you want you need share more details.
Question: Why are you linking animation and audio? you can deal them separately