I really can’t figure this one out. I have a timer that counts down, and want to add time to it when going through a trigger. Similar to how old arcade racing games did. But for the life of me I’m getting nowhere. I’ve searched for help on it so many times but the results I keep getting after wording it so many ways is making a timer which I already have. If I put checkpoint into the mix I get results about respawning there, not the kind of checkpoint I mean. Further if I say trigger or box trigger, I get general results about those and nothing on adding time.
So I try to do it myself with all results being exactly the same. The timer doesn’t react, it carries on counting down like normal. I’ve tried stuff on the game mode where my timer is. Tried doing things in the level blueprint where I have the onactorbeginoverlaps for moving bits of the level around. Tried it on the trigger itself, the player blueprint too but all results are the same. Of course, being on different blueprints, allows different methods so trying what I do on all of them is a headache and I have to try rearrange it. My current attempt looks like this, it’s all wrong I know. The first one is in the game mode blueprint and the next two are a couple of tries in the level blueprint.
OK redoing the timer makes it simpler, I even have the game over screen with the timer widget now instead of being on something else.
Now it’s just the extra time through checkpoints. I’m still looking that up. But my actual timer is simpler now, thanks!
Edit
And yeah the secondsup and down was me trying to make it clearer to me which seconds were up or down, instead of just using seconds. But I realise that’s just splitting hairs so I did away with it.
I have a widget for the timer, that’s holding all of the information regarding it except for the level blueprint which is being used to display it. Currently nothing else is interacting with the widget.
The level blueprint does have onbeginactoroverlaps which do point to the checkpoints, and is currently depending on the checkpoint, changing the scenery.
In the past I did try to link them rather unsuccessfully by copying variables over to the level blueprint and using the onbeginactoroverlaps doing a >= to see if the time is still running on overlap when the player goes through it and add on the time, but that did nothing.
On the actual trigger/checkpoint blueprint themselves, I tried doing the same there with their eventactobeginoverlaps but got nothing from it. I tried creating their own onbeginactoroverlaps for them too which didn’t work.
But for now, the timer widget and the checkpoints are unlinked.
I used a tutorial on creating it, and while it doesn’t use set timer by event, it does use set timer by function. Apparently they can be used for the same things.
What I made with the tutorial.
This is on the level blueprint, displaying the widget.
And these are the triggers shown in the level blueprint, currently not touching the widget.
The video I followed. He uses milliseconds but I did it in a way that doesn’t use them. I didn’t use my character, I wanted the time to be linked to the level instead. I wanted different levels with different times. How to make TIMER in unreal engine 4 and 5 - YouTube
The advantage of moving you logic to an actor in the level over the Level Blueprint is that you can have multiple timers, you can also have multiple instances with different functionalities and you can use it on more than one level.
“Remaining Time” defaults at 60 seconds. Timer loops every tenth of a second and deducts 0.1 from Remaining Time, then checks if Remaining Time is <= 0.0 … If so the timer is cleared and Time has elapsed is called. Thus ending the countdown/race etc.
Lap Box (simple box collision) triggers Increment Time… adds 60s to “Remaining Time”.
I’m a little bit stuck on the arrays. I create it, but it won’t let me add any of the triggers in the level to it. I can click the magnifying glass and it’ll bring me to my level but I still can’t add it. I am supposed to be doing this on the timer blueprint? If I read that right.
But then I’m a little confused on brining over the timer to an object. I ported the logic over and it compiles. But without the widget, it doesn’t display and it doesn’t seem to countdown either, the game over screen when the time runs out never shows up anymore, so I don’t think I brought it over right. And it is placed in the level too.
Unless you mean don’t move anything, but tell that new timer object instead of the level blueprint to display the widget. If that’s it, then it shows up.
Rev0verDrive
Sort of. It’s a linear road up until a certain point before a split, then there’s a checkpoint that will add more time to the timer so you can carry on. Similar to old arcade games like OutRun.
Oh, I was doing it in the wrong place, not the actual editor. I was trying to add the array elements from within the blueprint itself, instead of going to the level and clicking on it and then adding them to it from there. Sorry about that, I get a bit thrown off sometimes when things look so similar.
I followed what’s in the event graph, and I got it to print the message.
Again, this is super barebones. You can then try what @Rev0verDrive that solves a small time you’ll lose when adding integers mid seconds… or you can try find a way to avoid that loss keeping timer every second.
I found this bit quite difficult, I couldn’t get the timer to display at all. And I recreated all that is there.
I did manage to get the timer to display eventually, but to do that I linked it to event begin play. It counts down now, but only to 00:01. It prints the message a little after that as well, so it seems to hit 0, but hangs at 01. If I take it off event begin play it’s not there at all again and time is up never prints. The seconds and minutes texts are set to variable.
It also ignores the checkpoints and no extra time is added on.
Here is what I have when both on and off event begin play.
Where am I adding to the time? Do you mean where stuff is linked up? It’s the same. Noticed it didn’t update and tried a few connections that didn’t go anywhere.
I also linked up the create widget to the event begin play, which broke links to the custom event, so I used sequence to they could both be used. When I go through a checkpoint, only the message about passing through it shows up and the time isn’t added on to or changed. All of what I have.
Yeah it’s quite a bit to take in. I can see where the timer is, where it is rendered on screen, the end of the timer to trigger the end text and the first bit where the overlap triggers the checkpoint text.
It’s unclear to me where it connects to allow the timer to update. I can see those systems working independently, but not where they should be together.
I thought I could add something to the CE_Overlap bit. Like put in something that would add the time and direct it to the timer, it didn’t work.
Here’s a series of attempts. I don’t think it’s what you had in mind, but it’s all I could think of.
This is close. The ++ node all it does is adds 1 to the variable that it has connected. In this case I think it is adding Seconds = Seconds + 60 + 1. I could be wrong, I would simply not be setting to anything.
This is the logic I think you are after:
Timer runs every 1.0 seconds.
** if Seconds >= 0: Decrease Time ( --Seconds ) and Update Widget.
** if Seconds < 0: Stop Timer and Do Stuff.
If player overlaps checkpoint: Seconds = Seconds + AddedSeconds.
Rather than doing it trying to make everything work at the same time, do it step by step:
Timer prints something every time it runs ✓
Timer --Seconds ✓
Timer stops when Seconds < 0. ✓
Overlapping checkpoints adds to Seconds ✓
Widget Updates ✓
Start from scratch if you have to ( I do this a lot ). Do one at a time and only move to the next when you can prove it’s working.