Problem with my game code

Hi all, im currently making a game for a project for my university assignement. I’ve got a wave enemy system included in my game. I managed to make this work, however my AI mesh no longer gets damaged and is unkillable. But the mesh i spawned in on the map takes damage as normal. This is a cruical part for my game and would greatly appreciate any help or advice. I cant think of why the spawned in AI take no damage. There isnt even collision events i can enable.

Any help would be greatly appreciated, this is the last mechanic i need for my university project and i just cant get it working.


image
image
image

It would help if you actually shown how you deal & receive damage.


@Everynone this is all the code for that, my apologies

  • does this trigger?

  • you can remove that cast node
  • what is the value of Base Damage?
  • never compare floats like this:

image

Use Nearly Equal instead.

This does trigger yes.
The base damage is 20, also this is a clip of the issue happening

Did you try it without the cast? How come does the first enemy die? Are they of different class?

im Going on to check that now, but now that you mention it im sure theres a class for the damage, i should remove that i dont know i can add it to the other blueprint

If you cast, you’ll be only able to deal damage to that one class. Apply Damage is happy to accept the Other actor pin. And then ensure that every class that must receive damage handles this script:

image

Or look inheritance - ideally, this should be handled at the base class level.

Okay it still does not work, i even added the enemy tag to the actor blue print

This does not help your case. What does not work? Be specific. Debug it, use Breakpoints and Print String, observe data flow using the debugger - see where the messages go.

The spawned in enemys dont take damage, at all they have the same class tag and also the damage code now in there

You should not be using tags for any of this, nor Casting.


Simplify it, remove complexity if you cannot keep track of your own script (which is normal, btw):

  • in the enemy:

image

  • in the projectile:

Just this.

Without the tags the NPC no longer takes any damage

Tags have nothing to do with it, don’t use them here. See above please.

1 Like

Its fixed! I removed the tags, and the projectile BP had something to do with only damaged if they have tags, now all enemies get damaged and everything works.

Thank you so much for helping, i was really stuck, im still newish to unreal.

1 Like

Cool! Also consider fixing this bit up:

There’s no need for a clamp, the above will never fail.

1 Like