Increasing enemy difficulty, references potentially not working?

Hello, I am trying to increase the difficulty of my enemies as the layer kills a certain amount of them. I have set up this code in my player controller:


Which will call this method in the enemy script:

As I reach the threshold required to trigger the Increase Difficulty event, nothing is increased. Same damage, same health. The print statement at the end of the first screenshot is being triggered which makes me think the code is being fully executed but maybe I have the wrong type of reference set up?

It is worth me noting that I use an enemy spawner to continuously spawn enemies (once every 5 seconds) meaning when the level starts there are no enemies in the scene which, I believe, means I cannot make an object reference.

Any help/insight would be appreciated, thank you.

You’re doing it to one enemy only:

And we don’t even know which one - is this intended? Did you mean to:

No my intention is to do it for all enemies currently active in the scene and any that will be spawned going forward, this foreach will cover that?

It will cover existing enemies. But you will need to spawn new enemies with boosted stats.

How can I do that then?
Was hoping my current method would allow me to apply a permanent increase to new spawns.

That’s not a thing.


Add a difficulty variable to the enemy BP and flag it as in the red frame below:

Execute your existing event in the Construction Script. :up_arrow:


When spawning new enemies, you get to decide how strong they are:

You will need to increase this value when a threshold is reached - something that the spawn manager / game mode can be responsible for.

1 Like

Got this all set up. Would I be right in assuming it is best to do all my difficulty calculations in my player blueprint then get the difficulty inside of the spawner blueprint?

Visualisation of what I mean:
Spawner script


Player script

You could but it’s not optimal, unless the project is really small or you’re just experimenting:

  • the player class should not care about such things, it will be busy doing other, player related things
  • for defining global difficulty level, it’s common to have a spawn manager / use game mode / game state
  • it’s quite normal to have it split between a manager that handles global difficulty and the many enemy classes - each doing its own calculations. An Orc Brute will level up differently than a Fire Wizard.

I’d keep this in the spawn manager. Btw, your cast is not connected to anything.

1 Like