I’m not sure what I’ve done wrong but for some reason my player damaging enemy code only works after overlapping the collision?
For example:
Only once per overlap can the player damage the enemy without leaving and reoverlapping??
(Here’s a video example)
I’m not really sure why this is- this is my code for the logic. If anyone has any ideas I’d be greatly appreciative!
Zoomed version 1/2
Zoomed version 2/2
Full blueprint (there’s zoomed versions too in case this is too hard to read!)
You lack a secondary execution (‘Interface’ or ‘Custom Event’) before the ‘Do Once’ node. You’re currently using your ‘On Component Begin Overlap’ as an execution, which only happens once.
What you might do instead is call a hit execution (‘Interface’ or ‘Custom Event’) from the player on attack and only use the ‘On Component Begin Overlap’ to set ‘Close Enough GNOME HIT?’ true or false.
Or, you can extend your loop back to the ‘Do Once’ node. Your ‘Hit?’ boolean doesn’t trigger anything after the first overlap because your loop merely resets the ‘Do Once’ node. If you add a ‘Sequence’ after ‘Chase Gnome’ you can connect the second pin to the execution pin of ‘Do Once’.
UE does have built-in ‘Apply Damage’ and ‘Event AnyDamage’ nodes to simply things, but if you’re happy with your setup, one of the above is all you’d need to change.
The Loop won’t work like that unless you call teh reset execution pin on the do once.
Either way, is probably better to put the attack logic on the player and have them apply the damage. Probably also better to use a timer instead of relying on delays. Sorta like this:
On Begin overlap event there, first I check if the other actor has the tag “Enemy.” You can set that in enemy blueprints by searching for tags in details tab on the root component. If true, I set other actor as target, then start the looping timer. I’m using third person shooter project here, so you’ll just need to plug your own attack logic into the custom event.
On End Overlap, I simply check if the other actor was the target then clear and invalidate timer. Should probably set target actor to null too. But I did this real quick and dirty lol.