Emergency, Healt and Damage

  • it’s not safe to rely on == with floats. Try:

image

Ideally, also check it it’s below zero.


  • I am a bit confused by the script, though. You seem to keep health in a character but attempt to destroy the BP you’re showing.

  • also, you’re casting the Controller to Pawn (?), which makes no sense and will never work - the cast probably fails - could you double check?

  • if this script is already in the Actor we want to destroy once its health goes below the threshold, there’s no need to cast, just call the function directly

  • and lastly, you call it on Begin Play - how is this supposed to count health if it only happens once, when the actor is spawned. Did you mean to hook it to a node that triggers when damage is received?


So yeah, lots of things are going on that I do not understand. Under regular circumstances, the player character would have something along the lines of implemented:

I am ignoring the Damage Type pre-processor which should be probably involved in all this. It might be too early for this.

2 Likes