how i could stop countdown timer when the player reach end of level ?

Hello, I have implemented a time trial for a racing game but the problem when the player crosses the finish line the timer continues to run in the background this is an inconvenance because I made a win widget and a game over widget.

For the victory widget I made an actor blueprint (BP_Finish Line) with a collision box that when the player touches the box the victory widget appears on the screen.

For the Game over widget I made it appear on the screen when the timer reaches 0.

The timer continues to rotate in the background after the player crosses the line which normally displays the victory widget on the screen but as the timer continues to rotate in the background this gives this kind of situation…

Against-the-Clock-Unreal-Editor-2023-08-03-17-18-54

I am having a near identical issue with a game I am building. After looking at the screenshots of your blueprints, which are very similar to mine, I am wondering if there is something missing. One person suggested using “Clear Timer by Function Name”; however, this requires the “timer process” to have a function name or event name to which I am bereft in my understanding of how to apply. I am eager to hear of any solutions you find to our common problem. :slight_smile:

After several reflections I decided to try to use Set Timer by Event so I created an event that will count the minutes and seconds but for the Game Over and stop the timer I have no idea how to do.

Timers have handles:

Use it to either invalidate or pause it.

I try with another method using the set timer by function name the timer works but the problem is the condition to trigger the game over because I don’t know if I should do a function or use the branch ?
Screenshot 4

For the BP the finish line I chose to use the function Clear Timer by function name however I still have the same problem when the player crosses the finish line the timer continues to run and the game over is triggered while the player is supposed to have won so that is what must-I do?

Can you try with the “Pause Timer by Function Name” node ?

I tried with this function but it doesn’t work

You’re plugging in a Component as Object. Is this intended? Does this component have the timer function?

Did you mean the Actor instead?


Any reason why you cannot call a Custom Event in the target actor that owns the timer? Manually typing function names is asking for trouble.

So what if I did it this way it should work?

If the target actor has a function with the specified name, then yes. We don’t know what value is in that string variable, though.

In this case it should work but if it does not work?
Screenshot 4

Your function is in the Player Controller:

The BP_Finish Line does not collide with the player controller - they have no collision:

I am assuming these are the cars that finish the race, right? So you’re asking the car to stop the timer it does not have. If it’s the controller that is running the function, ask it to stop it:

image


Also, none of this manual counting is needed:

If you used a timer as originally suggested, you’d have everything ready:

The timer counts the time and you can format the display it as you want. Consider watching a quick YT tutorial to see how it works.

Up to you, ofc. Good luck!

1 Like

thank you for the info I will try to do this method

Try the controller first. It should work.

I adopted the method you recommended for the timer and then I changed the code in the BP finish line by asking the car to stop the timer and I also tested in the viewport and it works.



1 Like

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