Track percentage of deaths in an array

Hi everyone! I could use some help with creating a piece of blueprint to track the percentage of deaths in an array. I know how to spawn my enemies and add them to said array, as well as detect their deaths but I would like to:

  • Decrement in percentage the enemy array
  • trigger an event once a certain percentage has been reached in that array of enemies

Number of enemies can vary which is why I would like to use percentages.

Any advice would be greatly appreciated,
Thank you!

I’d be glad to help!

Though I’m not sure what you mean by


I’ll be using a function for the death percentage as it’s best we use local variables in this case.
Said local variable:
image

For that function, we want to loop through the enemies. For every enemy, we want to check whether or not it’s dead. If it is dead, we increment the DeadCount.
After we’ve figured out how many are dead, we convert that to a percentage using simple math. In order to get an accurate percentage, we first convert DeadCount and Length to floats- otherwise it would automatically round to the nearest whole number.



Triggering the event is very simple. For it, we’ll also be using an event. This event should be called whenever an enemy is killed. In the event, we simply get the percentage using the above function, check whether it’s above a threshold of your choosing, and if it is- fire whatever event you want fired.

This is wonderful, thank you so much for your help!
The math at the bottom of your first screenshot was what was tripping me up as I did not imagine this as a conversion and was thinking about it completely the wrong way :sweat_smile:

Thank you again!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.