No announcement yet.

how to avoid multiple events triggered by On Begin Overlap

  • Filter
  • Time
  • Show
Clear All
new posts

    how to avoid multiple events triggered by On Begin Overlap

    i have simple setup where player swings his sword at enemy. Sword has collision capsule that triggers event OnBeginOverlap.
    Problem is, by the time animation moves sword trough enemy's body, i get 4 or more trigger events OnBeginOverlap which applies damage multiple times on one swing. My attempt to use DoOnce makes no difference. Is there a way how to make it so it deals on one 'dose' of damage per swing? I would prefer not to be time based as different attacks have different animation speeds.

    Thank you,

    here is my simple setup

    Maybe holding a reference to the enemy that is currently being damaged will help you. If an overlap occurs on that same reference when you are still performing the same attack, you can safely ignore applying more damage. Just remember to make sure that you clear the reference when you finish performing an attack so that you do not make that reference invulnerable to future attacks.
    Im an Moderator on UnrealSlackers Discord! Which is a Community driven group of likeminded people here to discuss UE4! Join UnrealSlackers on Discord!


      Way back when I had this same problem in Unity, I solved it by creating a temporary array that would hold a reference to every actor that I was dealing damage to. On the OnBeginOverlap event, I just checked to see if the actor was in the list. If they were not in the list I would, I would deal damage and then add them to the list. This allowed me to do melee damage to multiple entities at a time for a single weapon swing while actually using the blade of the weapon to deal the damage. I'm at work right now, so I can't make you a blueprint image to show exactly what I mean, so hopefully I described it well enough.

      EDIT: I took another look at your image, and it looks like you are generally going in the right direction. The issue, however, is that you are creating a new blank array every time you have the OnBeginOverlap even run. You want to create this array withing your actor instead and just clear the array when you begin a new attack. The way you have it now would cause the list to be empty each time something overlaps, which can be multiple times per attack.

      EDIT 2: Actually, that previous edit is what I am assuming that you are doing based on the code that you provided. I do not actually know how you are handling the array that is passed into ActorOverlapMelee, but either way making it an array to pass into the melee event is redundant because the OnBeginOverlap event will always only return one actor as this event runs once per each object that overlaps.
      Last edited by Epsilia; 08-13-2015, 11:31 AM.


        Hi, thanks for looking at my problem.
        this my setup where melee weapon sends input and overlaped actors to player controller which in turn sends damage data to overlaped actors. i want to have system with critical damage and so on, so all damage handling is one place.

        Is there any chance you could please provide me with simple (i hope it is simple ) example how to do setup you described in your EDIT1? i have no idea how would I go about it.
        Right now, i'm considering faking it. Player sword deals 15 damage and my current setup triggers each enemy 3-4 times on each swing, so i plan to divide sword's damage by 3.5 and be done with it. Kinda stupid, but desperate times... What worries me on my fake approach is I'm just postponing problem for later where this cheat won't be enough.

        Thanks, H

        Player controller setup looks this.


          I was meaning to post an example yesterday, but it slipped my mind when I became busy. I'll set myself a reminder so I hopefully get to it today. It may not be until really late though. Your second image is somewhat in the right direction, but I feel that there may just be a simpler way of handling melee. My example is going to be basic and not have a combo system, but I expect that it should be easy to add with my example if you choose to build something similar.


            oh, your help is really appreciated! no need for combos or any fluff, just basic logic how to set it up, i'll add the rest. thanks again!