How to divide a health variable by same amount of itself when it is constantly changing ?

The bar doesn’t update :melting_face: ( thanks for testing )

I even tried it with a bind! - nothing. It’s like the bar initializes, and then never ticks again…

Hmmm… Just made a new project and it works… not good…

As I suspected. This

image

in the new project produces a constant list.

In the non-working project, it only ran twice…

Ok i finally manage to fix this :sunglasses:. So the solution was what Clockwork mentioned at the very begining - to get a max life variable and divide the current life with it. The problem i had after creating the Max life variable was that i couldnt access it from my spawn system till i found work around (Interfaces).

Btw @Everynone i used the widget logic from your example above and put it as well just after the damage event so that i no longer needed to use the “bind” function directly in the widget bp. And i was glad that i dont need to use this function anymore which is equal to event tick so not performance friendly i guess… But then i found out that i do need to do an event tick to make it work because of my spawn system :confused: else it refresh the life amount in the moment after i hit an enemy first. I tried to put it on event begin play but that awso doesnt work and it must be updating in the exact moment after my spawn system spawn the new enemies. So i tried it to put the widget in the spawner but that failed for some reason. Anyway now it is back on event tick with a delay of 0.2 sec and im wondering if that would still cost a lot of performance if i have lets say around 100 enemy’s on the screen ? Widget show up only in close proximity tough so not visible most of the time only visible to nearby enemies.

Here is what i did


and here on the spawner interface current life and max life variables

Now only 1 problem left that the life amount dont go up anymore after a new wave spawns and i am not sure why this is. Previously that worked but the widget was screwed now is the other way around :pensive:… The increment node dont work as it did. Maybe you guys have an idea how i can now respawn the next wave with adding addtional health to the enemy ? Btw thx for the help :vulcan_salute:

1 Like

Do not use Get (all) Actors of Class or Tick for this, no matter what online tuts telle you to.

1 Like

Do you mean i should replace the get all actors of class on my spawn system to increase performance? And if so what should i use there instead ? My spawner needs to cycle/loop between the actors to spawn and my settings for each wave and settings which enemy exactly and how many of them not sure what or how to replace that. Wait acctually i did put that after the spawn system on my own so it wasnt mentioned to be there lol… I had it from a tutorial but then i try to expand it a little so with what could i replace that ?

Here is how the whole BP look like and it ended where the GET node is after that i inserted the rest…

Oh lol you were right i had the enemy references just 1 node behind on this Get node which make the whole thing work as intended. Really awsome that you see this and i bet that would have fall back on me at some point with heavy performance hits and it just saved me a lot of work for the future ty :smiley:

Now last thing on this left is how to increment life on my enemies when they respawn just after the get node. it worked previously but now it dont. It looks like the increment node and +200 add print string correctly +201 life but it dont apply this value to the current live and max life variables which are in a simple interface. So here must be the problem not sure how to solve it tough and testing around right now…

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