Confused About Hit() Event in This Lecture

Hi, all. Just having a little trouble understanding the code that was implemented in this video, specifically the changes to fighter.cs. I understand the logic of what is happening in the Hit() event, as far as how the damage gets taken. What I’m confused about is how is AttackBehaviour() triggering the Hit() event? I’ve been looking through all the scripts trying to figure out where Hit() gets called, and I would appreciate if anyone could further explain.

Cheers

1 Like

Welcome to the community, @dingo131

Hit() is being called by the attack animation. You will find that the animation has an event defined at a specific point in its timeline:

image

When the animation reaches that point, it will try to call that function on the game object that the Animator is attached to. The function can be in any of the components attached to that game object.

You can read more about animation events here:

3 Likes

Thank you so much, @bixarrio

I had completely forgot about that.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms