Countown before death, unless overlapping a light

Hello all,
I’ve been trying to implement a countdown when the player is in the dark, and at the end of the timer, if he didn’t overlap a light, he die. I tried to copy a bit what I did with my lantern, that use a timer too for the battery, but it really doesn’t seem to work.

So, every tick, the game look if the player is overlapping. If not, the timer begin, and he have 5 seconds before the destroy actor. The overlapLight is set to true when overlappigng one of the light I have in my level, but nothing happen at all. I tried to print the string of the countdown, but it doesn’t even appear.
Any ideas ? Thanks in advance !

i would suggest you to break down the blueprint in smaller piece

1, create an actor , name it “LAMP” inside add a point light and a triggerbox .
2, on event overlap, pin out the “other actor” and print his name or class.
3, place some LAMPS in the level.
4 Get your actor or pawn … move it inside the lamp trigger, do you get any print?
if yes, continue otherwise is collision problem!.
5 Now the light problem.
Beware that you can have two LAMP, really close and so, you can leave the Lamp1 while still in the light of Lamp2,
so how do you manage to check if you are in the light of any lamp?.
this is something you can manage in a lot of ways and you should build a perfect fit for your project… so.
Lets say that for now, all your lights are really distant. so your char always leave a light before entering a new one.
If so
6 create a custom event- call it “TimerDark” add a “timeline” double click it and set the timeline to 5 seconds ot whatever you want Plug in the Finish some thing like a Print “You are dead”
6.5 create another called “Stop_timerDark” and plug it in the stop of the timeline node.
7 Set the LAMP, pin out the “other actor” on overlap-End & cast to “player-actor” the right class you are using for the player. Make the lamp call the TimerDark of the player. (play from start)
8 Set the Lamp, other actor overlap-begin… cast to … and call the event “Stop_timerDark”.

Should it work
but as you can see, you have to manage the multilight in someway and add a “kill player” instead print

Hey ! Thanks for your answer. It works, but only with one light. If I have multiple lights, that I overlap one, then I go to another one, my character will die after 5 seconds. But if I go back to the first light, it’s ok. The lights are from the same BP.

So, I changed a bit my thing, I replaced the countdown by a progress bar that goes down when not overlapping, and up when overlapping, and with this bp, it works.


I just have now a little problem. This works with the lantern the player is carrying too, but if the player go throught a light with his lantern on, when he’ll stop overlap, the game will only see the “end overlap” of the light, and not the fact that the lantern is on anymore, and the bar will go down. Is there a way (I guess there’s one x) ) to prevent that ?

Edit 1 : I fixed a part of it. Just created a boolean in the lantern, that is set to true when the player turn it on. And so, when the character end overlap, it check if the lantern is on, and so set overlap light to true if it is. But now, it’s when I turn off the lantern when I’m in a light that is a problem, it go down again x)

Edit 2 : I tried with a set timer by event, checking if the lantern is on or off, and setting overlap light to true if not and still in the light, but doesn’t seem to work. When I leave the light, the bar doesn’t go down.

Well well well, it seems that my blueprint for one of my lights works :

At least, it seem to do the trick, but I don’t know why, I have an error everytime I stop the simulation “Accessed none. Trying to read property K2Node_DynamicCastAsThird_Person_Character”. It do that for the branch and the “set overlap light” above. Any idea why ? Except that error, it seem to work fine. And if I plug the “Set overlap light” in the “True” of the branch, the error doesn’t appear, but then again, when I turn off the light while overlapping, the progress bar goes down.

If any question, just ask, this bp might be a bit “dirty” x)

Sometimes is hard read other people blueprint ,
i rearranged the things.
i left out the movement, but they dont matter,

let me know if you get it :slight_smile:

Hey !
I must say that I’m a bit lost in this blueprint x) I see what you do, but not totally clearly ^^ Do you think we can “merge” the bp with the progress bar with yours ? (it’s the one I sent the 10/13/2020) If I understand it, the fact that the progress bar go down or up would replace the print string. (yeah, so now I don’t do a countdown anymore, but a progress bar, it’s a bit more visual)

Welp, I think I fixed my problem, and sweet jebus that was a bit dumb x) I see more or less your blueprint, but yeah, I guess it works more with a countdown than a progress bar. And my main problem at this moment was when the player was turning his light off when he was overlapping a light, and the progress bar was going down ^^
With that, it works, I just check if the light is on or off, if on, the bar goes up. If down, it check if the player overlap a light or not, and so the bar goes up if yes, or down if not.