Is overlapping component for attacks

Hi,

I’m trying to hit my enemy with the “is overlapping component” node that checks my own collision with the enemies’ collision. This is what I made, but it’s currently not working:

It used to work with the “On component begin overlap”, but the problem with that was that it didn’t always register my attacks, only when it started to overlap with the enemies’ collision. I wanted the attack to go through, even if the 2 colliders were already overlapping on start of the attack.

Thank you for helping me out with this problem <3

Hi and thanks again for helping me out!

I tried to follow the suggestion you gave me but it’s still not working, I think I must do some stuff wrong. I guess the second check with the mouth collision becomes redundant too then?
I set the “get overlapping actors” filter to that of the ThirdPerson_Enemy, so it doesn’t have to check everything in the game it overlaps with.

your still doing basically the same thing. im assuming that this script is meant to be used by the player right since its a input action. also im assuming that your player is not of the class enemy right. given those two things you have several issues here. first your player would not inherit from the class enemy so everything beyond the cast would not run. with that even if it did run you are targeting the player to damage. lets not dwell on all this however.

i made a very simple example that you could use (see below picture). when the attack event is called (input in your case) we get the actors overlapping the component we decide (a weapon in my case). then we use a for each loop which runs the rest of the script once for every overlapping actor. so for each overlapping we actor we ask is this actor of the enemy class, if yes we apply damage, if no we do nothing.

writing script is like asking a series of questions. in your case the questions asked are: is X overlapping Y, and is the other actor a enemy. theres many ways to ask these things so theres no one answer. in my example we answer is x overlapping Y via the get overlapping actors node. we answer the question is the other actor a enemy by identifying it via a cast. if you want to add in more conditions (questions) before applying damage then by all means, but thats the basics.

oh yea and you can actually eliminate the cast in my example if you wanted to and just use the class filter of the get overlapping actors node. the filter will do the identifying for you so then all you need to worry about is the apply damage.

Thank you for your thorough explanation, I understand it way better now and it works!

it looks to me like your issue lies in your cast. in your on overlap example you are casting the other actor to the enemy class, but in the attack event you are casting your player to the enemy class.

what you should probably do is to on attack event get overlapping actors then for each cast to enemy then do your script.

oh and your know theres built in nodes for applying and receiving damage right so you dont need to make your own custom events for that. this could possibly eliminate the need for you cast.