I created a perk that reduces zombie's health, but it only works on the first zombie.

Hi Guys, I’m new to UE5, recently I’m trying to implement a temporary perks system through blueprints.

At the moment I’m trying to make one that reduces the life of zombies (yes, like Instant Kill from COD.)

But, kind work but only for one zombie.

if i have 3 zombies on map, the first one dies with one shot and the other 2 die according to the normal damage system.

I’m using this code in the the AI ​​character blueprint, it is called through a event dispatcher that is activated when I overlap the icon in the world

Inside overlap actor there is only this code:

image

The wole code inside AI Character:

If any of you can help me, I would be very grateful.

What is ‘zombie base BP’? Surely you need to call it on all zombies?

( probably a dumb question )

Is the AI Character. The only one I have in the game right now.

Does this character contain the dispatcher, and the zombies have bound to it?

Then it would be

Yes, In actor overlap I call the event dispatcher and in Zombie Blueprint I Bind to create all the code.

Right, that’s why I’m asking what that extra bit is ( Zombie base BP )…

1 Like

The most important bit here is the bind itself. Can we see it?


Is there a reason why this needs to work this way? Why not let the player use a special Damage Type zombies interpret as insta-kill. This way they can keep their health, no need to dispatch anything. They are simply dealt as much damage as they have health.

You could even wrap this in a component for the player to pick up but it already might be overkill. Would it work for you?

1 Like

image

If you’re referring to this Zombie Base leaving the cast node, the logic in my head was;

All the logic would only be triggered if the player passed over the overlap actor, that’s why I made the cast. and then I got the zombie variable which is where the event dispatcher is. inside the Zombie character. I didn’t want to make two casts within the overlap actor.

Using these Apply Damage and Any Damage nodes would actually be easier. it seems. but I was following those “Create an FPS” courses. and in this course the instructor created a somewhat complex Health system so I don’t know if I could adapt and make everything work.

Fair enough.


Coming back to the main topic. For the dispatcher to work, you need to bind it. We’ve yet to see you do it, though. Could you show how you register the event?

Atm, you are clearly sending a message to a single zombie instance - something you should not be doing at all for this to work.

  • all zombies register with a dispatcher (can we see how you do this)
  • player calls the dispatcher / or picking up an item calls the dispatcher

That’s it.


You said you work with a temporary perk system, why not give this perk to the player instead? Player gets a perk to insta-kill zombies. Why spam all 4000 zombies we may not even get to see? :person_shrugging:

I hope you see what I mean.


You could make it work the way you want, it just seems unnecessarily convoluted. But it could work, sure. Ensure the zombies register with the dispatcher first. Then call it.

I don’t know exactly what “how you register the event” means

As I said I’m new to Unreal and English is not my native language.

so I don’t know if that’s what you meant but the event is called by the event tick

Regarding the Zombie instances, I only have one. I just copy it and paste it on map. So it wasn’t supposed to work since they are the same zombies using the same code?

I don’t really know what I’m doing. When I think about killing zombies more easily, I immediately think about reducing their health.

I totally understand you and it doesn’t have to be the way I’m trying to do it.

I wonder how I could make it work by giving this perk to the player instead of changing the zombies health?

1 Like

Let’s try this without the event dispatcher for now:

  • this is the zombie BP, we flag it so it can be killed instantly:

  • we collect the pickup:


See if you can implement this. This should work in pretty much any system. Definitely not the best solution around, though.

You said up above that you have three zombies.
A blueprint is a class but actors are objects (which are instances of the class.)
When you get “a BP_Zombie” in the node graph, you’re getting the instance not the class. Any changes you make, only happen to that one instance, not to all objects of that instance.

If you need some parameter that affects all objects of some instance, typically the best place to put that, is in your GameMode.
E g, Zombie would know “how many hitpoints do I have?” by asking the GameMode for the ZombieHitpoints parameter you add there, and then when the player gets the power-up, you change that value on the GameMode instance. (The reason this works, is that there is only ever one “the” GameMode instance, even though the GameMode blueprint is still a class, and the GameMode itself is an instance of that class.)

1 Like

I am specifically avoiding enemy class inheritance, treat Zombie as the base enemy class; here to make it more relatable. Do note that what’s below may seem complicated at a glance because it’s not a solution to your specific issue, it’s a solution to 99% of issues in vast majority of scenarios where damage needs dealing.

This is still somewhat simplified and can be improved further but that should be tackled once we know the scope of the project.


Consider the following:

  • I’ve created an enumerator (official) so I can distinguish between enemy and damage types easily:

    image

    The base enemy class has this variable, each enemy knows who they are if we query them. This one is a zombie:

  • in order to handle Damage Types, I’ve created 1 base damage class, and 3 children:

    image

    image

  • the base class damage describes how damage is done in general:

We take the incoming damage, maybe apply a crit, maybe it’s enough to kill the enemy outright. We then spit out the processed value.

  • normally, the player deals damage (just by clicking enemies for simplicity) like so:

  • the enemy receives said damage:

We use our damage class for processing (see above).

  • the interesting part kicks in when we start using other damage type classes. This is the damage type that allows us to immediately kill zombies (and zombies only!):

Let’s grant the player the new damage type:


Other enemy types remain unaffected:

Note how all the processing, damage mitigation, crits, health can be handled inside the damage classes. We no longer need to clutter the enemies or the player with any of this.

1 Like

Once the upfront cost of setting it up has been paid, things get straightforward:

  • using this Damage Type will allow the player to always crit, and crit much higher:

Also, note how we do not need to inform the enemies about any of this. They will deal with the damage when it happens.


The above can be combined with dynamically spawned actor components. This would then work like true perks - where the player gets any number of temporary or persistent abilities.

1 Like

This concept of DamageType is something I haven’t heard of before.

It will definitely be something I will be researching in more depth over the weekend.

I want to thank you for the time you invested in posting this mega thread.

By following this method, I believe it will be simpler to achieve this perk system.

So, Thank You!

1 Like

Just an update, it worked like a charm. At first glance I thought it would be too complex for me to reproduce in my project but it worked very well. So once again, thank you.

1 Like

Woah! That was quick!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.