Healing

Hi,

Thanks for the course, it has been great building this.

I have added med kits to the game, but recall that it was mentioned that the TakeDamage function could be used to apply negative damage to heal. TakeDamage takes an event instigator though, a controller reference, but I can’t get a controller for an AActor can I (well, I can’t work out how), so I’ve just called the HP variable on my shooter character and added the health directly (checking that MaxHP hasn’t beed exceeded).

Is that a bad approach? How can I use the TakeDamage function from a collision with a Med Kit, if that is the better approach?

Thanks,
Matthew

You can just pass in nullptr.

No cause only pawns are controlled and have a controller.

Actor->TakeDamage(-50, FDamageEvent() /* or derive your own */, nullptr, /* the medkit, probably `this`?*/);
)

Ah, simple… Thanks, I didn’t think of that! Also good to know I don’t need to build my own FDamageEvent unnecessarily.

ShooterCharacter->TakeDamage(-HP_Healed, FDamageEvent(), nullptr, this);

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

Privacy & Terms