I have a ranged attack where if the enemy is attacked close to the player they will take 150 dmg and if they are further away only 50 dmg, I done this using 2 collison boxes on the same actor (the attack) which is then spawned in. However if the enemy is in-between the 2 collision boxes they will take the combined total of 200 dmg, how do I prevent this? Thanks.
I see you’re calling the same function (which is named “caught”) after both of those collisions. You can create an int type variable and increment it at the start of that function. Now before applying the damage, you can execute a really short delay node and after that check if that variable is greater than 1 or not, and only apply damage if it’s not. If it is however, then you can choose to apply just one of them by plugging in either the lower or the higher apply damage function to the other output pin of the branch node we’ve used to check the collision count. Once that’s done you can go ahead and reset the variable back to 0
Though if you don’t want a delay before the damage is applied even if it’s so unnoticeable, you can do the same thing except executing the checking part before the apply damage functions, but rather placing them after those. This time, you can just revert the damage by plugging either the higher or the lower apply damage function to the output pin of the branch node which gets executed if the variable is greater than 1. You also shouldn’t need to create a new function for that, just negate the value you’ll insert into the damage value pin of yours. And again, remember to reset the collision count variable back to 0 at the end!