How do i permanently update an integer's value?

Hi,

I am working on a tower defense project and usually i post screenshots to visualise my issues for you but i feel this could be simply explained in a brief fashion.

Im in the debugging phase of setting up my win/loss mechanics and have an integer setup in my enemy blueprint with the intention of keeping track of how many enemies are left in the level. In this case the value of the integer is 28.

Apon the enemies death i want to be able to subtract 1 from the 28 value and for this to continue to happen each time the enemy dies.

What i currently have set up is a set integer node which has a int - int node and a get integer node connected to it. This then connects to a print string for debugging purposes. This works fine, as apon the enemies death the value goes from 28 to 27. However when the second enemy dies the value once again goes from 28 to 27 as opposed to the intended 27 to 26.

Im aware that what is probably happening here is that the get integer node is being repeated with the second enemies death therefor setting the value back to 28 but can anyone please help me with a solution so that the integer continously counts down?

Thanks :slight_smile:

Put your integer in a shared place such as a GameState subclass. Then on death reference the integer through the gamestate and decrement it.

You need to make sure you’re tracking the variable in a common place that you can access. I would suggest creating a new Blueprint (based on Actor) - call it Win Conditions Manager. Drag it into the scene. Create a reference to it somewhere you can easily get to (such as Player Controller). Then call a Custom Event on that actor to handle checking your win conditions:

87019-capture.png

This is overkill for a simple problem, but overtime you are likely to evolve other win conditions (such as points, achievements, etc) and it will be easier to implement all of them in a dedicated blueprint.