Double subtraction issue

Hi guys,

I’m experiencing something weird. This simple if statement gives me a non-correct output.

        if(lifeTime < 0f)
        {
            GameObject.FindWithTag("GameController").GetComponent<EnemySpawnScript>().enemyOnScreen -= 1;
            Destroy(gameObject);
        }

The subtraction on the variable enemyOnScreen is done two times instead of one. How’s this possible if the object is immediately destroyed after the subtraction?

This is probably because actual destruction is delayed until the end of the Update loop (after all objects are updated).