How do I optimize updates?

I suspect that at some point my game will start having performance issues.

For example, the health of an object is updated every damn moment. Even if it’s just standing there. How do I make the recalculation of an object’s health not permanent, but ONLY after the interaction of something affecting its health?(taking damage, healing, etc.)

I think it will have a good effect when there are hundreds of objects with a health on the screen.

( And it’s not just about health, but about optimizing updates for any variables at all)

I would say health is your least problem
With tons of objects more performance hungry thing is that you move them

FOR EXAMPLE
I always change health bar variable to shrink with players HP and i do not use trigger once for it or any condition
When i seen many ppl either use trigger once and/or put condition in that event
Player is in collision with weapon or something like that
So it only update bar when player get hit

BUT they do that just cause they know it is better to update something less than more
NOT even checking how much of performance they gain from it
Where gain is like next to none

And you are pretty much going same route
You will lag your game A LOT faster and easier with moving your objects
And not with how you manage their health

1 Like