I'm Making Health Reduce Consecutively While Interacting With An Object, But It Only Reduces Once You Touch The Object

Viewed 124

I'm trying to make health reduce while interacting with an object. I'm using Unreal Engine Blueprint. I want it so as soon as you interact with the object your health goes down, but once you stop interacting your health stops reducing.

Here's my blueprint: enter image description here

3 Answers

I would do this in three parts:

  1. On begin overlap, cast the overlapping object to the player pawn and if the cast succeeds, stash the player pawn in a member variable.
  2. Run a repeating timer that deals damage every x seconds to the pawn stashed in the member variable if it's not null.
  3. On end overlap, set the member variable to null.

This way if something other than the player comes in contact with the object, it's ignored, but when the player makes contact it starts repeatedly dealing damage until the player ends contact.

make private bool variable in the class. set it to true when begin overlap. set it to false when end overlap.

in Tick function reduce health when variable is true.

to be very simple...

fallow cpp way and make changes as in Tick function like the person above said ...

make private bool variable in the class. set it to true when begin overlap. set it to false when end overlap.

in Tick function reduce health when variable is true.

Related