In the level I’m working on, there is a specific number of enemy ai that will spawn in waves with time intervals between them(function for this was made with gamemode). At some point they will all get destroyed due to damage from weapons and other players’ attacks(and i have set up in each ai enemy’s blueprints to cast to the gamemode, get the number of enemies and subtract 1 from it everytime death occurs). It is at this point i want to display a widget notifying the player that he/she has passed the level. To do that, I simply ran a branch with event tick in the level blueprint to check if the number of enemies variable equals 0, if true it should display said widget on the viewport, but that didnt get displayed, so i scrapped that off and went for a printstring to check if its even registering the event at all but i didnt get anything either.
help and suggestions please, thanks.
If you have a lot of enemies, it my pass zero before you get a chance to check it. Best to try two things:
-
Put a tick on it that reports any change
-
Change your test to IF enemies <= 0 THEN print…
thats just what i did. still
Sorry, my comment was meant to say, check if <= 0
Edit: Holy ■■■■, that is so annoying, this thing keep taking away bits of my text…
I’m trying to say ‘less than or equal to’ should be the test…
Ok, first, don’t use Event Tick, it is really not optimized for what you want to achieve.
In you GameMode, create a function call something like OnEnemyDeath.
When one of your enemies dies, call this method in the Gamemode.
This method should handle your counter decreasing. Just after that, check if your values <= 0, and if yes, call your widget.
This way, the check for the number of enemies will only occur when an enemy is dying. It will be way more optimize than every frame.