Relative Content

Tag Archive for c#unity-game-enginemath

How can I add and subtract to a variable from multiple game objects without loosing the accuracy?

I have more than 100(close to 200) enemy game objects in my scene and 5-6 being spawned every second. I’m using object pooling and the objects are not being instantiated every time but only when needed.
I’m trying to record the stats where I can show total enemies remaining and total enemies taken down.
A simple mathematical function of addition and subtraction from respective game objects is not adding up to what it should be.
For example:
Total enemies spawned 200 (when I didn’t kill a single one)
I kill a lot of enemies in an instant but when I’m done killing them all, enemies remaining is not always zero.