Announcement

Collapse
No announcement yet.

Question about passing damage to enemies

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Question about passing damage to enemies

    Hey, so my question is pretty simple. I have a throwing weapon. This weapon has a hitbox. I do a collision check, if it hits the enemy the enemy takes damage. All of that part is working fine against every enemies hitbox. My question though is about if there's a smart way to pass in damage to ANY enemy that gets hit at once. I can get the array of overlapped classes,and know for sure all that is in the array is enemies due to the custom collision channels. Every enemy has a function called "takeDamage" Is there any way for me to essentially say "Whatever the first object in this array is, call this function" without first trying to cast to the object? Or do I need to do a one by one check? That seems inefficient to me.

    My idea that I had to solve this was to simply create a new invisible object called damage that spawns at the hit collision location, which would always be the enemies hitbox, and then pass in the damage/afflictions being done and then just create a "take damage" function for the enemies that checks for this "damage" blueprint and then reads in the values and takes the appropriate damage.


    #2
    If the collision matrix already filtered the array then simply "ApplyDamage" to everyone in the array or am I missing something? When you call ApplyDamage on an Actor then EventAnyDamage gets called so there is no need to cast it.

    Comment


      #3
      Well that's just one of the stupidities you face when you learn top-down I suppose. The number of hours I spent on this is embarrassingly high lol. Thank you so much for literally saving my mental state.

      Comment


        #4
        No worries sometimes you just need someone else to have a look... can happen to anyone.

        Comment

        Working...
        X