Create hitbox and actor tag:
Open Ninja BP, add Box collision in Component, name as HitBox (if player get in the box, ninja attacks and player healthbar reduces)
Set the hitbox position in Viewport
Select Mesh in compoent, change anim mode to Use Animation Asset
Aim to play to kick, untick looping and playing, adjust the intital position at the moment his kick at the peak point (should be around 0.7047)
Scale up and reposition the hitbox as follow, take different perspective (top and L/R) for reference:
Now can tick back play and looping on mesh
Go to Player BP, click on Player BP self in component, type tag in detail and rename them
Repeat the same in ninja BP (optional)
Create new task: DetectPlayerOverlap on hitbox:
Go to Behavior Tree, New Task, name as DetectPlayerOverlap
create variable and nodes as below:
Rename the character BP from Player1 to Player0
Back to behavor tree, create another task name as Attack
In Ninja BP, mesh, Change back anim mode to use animaiton bp
Go to Attack BP, Play montage node, change its play to kick montage
Go back to Behavoir tree, make a new sequence, add detectplayerovelap, and then new blackboard key attacking?
Add blackboard on attack node, set as below, and then copy and paste in Chaseplayer sequence, drag the blackboard on top,
key querry as not Set in chase player sequence blackboard
copy and paste on random roam sequence too, attacking as not set this time
Create Damage on player:
In Ninja AI folder, R click, create BP class, type animNotifyState, name as Ninja_ANS,
Open it, under +Add new tag, cursor move on Functions → click Override, choose Get Notify Name → then subchoose Notify Begin, and then subchoose Notify End (3 Eventgraphs are created)
In Get Notify Name, name Return value as follow:
Notify Begin (new type as query only):
Copy those middles nodes from NotifyBegin, paste in NotifyEnd, but plug Mesh Comp to Get Owner target, and set Collison Enable type to no collison
Open Ninja anim, kick montage, R click on the the row 1 under notify, select add notify state→ Ninja ANS
drag start and end dimaond from ninja kick starts and end (diamond box refers to hitbox being activated, i.e player only gets injury when he is in the hitbox during activated period of the kick)
Go to Ninja BP, duplicate a Hitbox, name as StartMelee? → Scale up the box size little bit more than the hitbox size (to let enemy detects if player is closed, then the hitbox size is to trigger attack)
Go to behavior tree → click Detectplayeroverlap node, change the hitbox node to StartMelee node:
Go to Ninja BP, hitbox, set its collision preset to custom, enabled no collision (i don’t need to do it, or else no damage worked), then click on component begin overlap
Go to player BP, add actor disable collison node at the end when player dies (i.e. ninja won’t have player box detected when he dies)
P.S. If set player death animation: