Download

Timers broken? Or am I missing something.

As the title says, are timers broken? Cause whenever I try to use a timer the action after the timer happens instantaneously. Just wanted to make sure I’m not missing something before reporting a bug.

Could you elaborate a bit on what it is you’re trying to do? If you’re just looking to pause execution for a certain amount of time, it sounds like the function you’re looking for might actually be the “Delay”, rather than a timer.

I’m not looking to pause the execution, rather I want the time information from the timer. I have an object that moves in a certain direction depending on if the player stands on it or not, if the player leaves the object it goes back to it’s starting position. The problem is that the object goes back over a set time. So it does not matter how long the player stands on the object it will always go back over X seconds. That’s why I thought about using a timer when the player firsts hits the object, and then get the elapsed time of the timer when the player leaves the object to move it back. So if the player stood on the object for 4 seconds it would move back to it’s position over 4 seconds. But the timer nodes seems to be ignored completely so I got no idea how to make it happen.

I’ve no idea about timers, but are you sure you need one? If the object is moving in one direction when the player is standing on it I would assume you have a “speed” at which it moves? Why not just make it move at the same speed in the opposite direction when the player gets off, and stop when it reaches it’s starting position?

If you really need the time though. Maybe you could make a float variable in your blueprint called startTime, and set it with the “Get World Delta Seconds” function when the player gets on the object. Then use “Get World Delta Seconds” again and subtract the startTime to get the time passed when the player gets off.

I tried the “Get World Delta Seconds”, but it seems I just got the time it took for the funtion to fire, so I changed it to Get Real Time Seconds instead and it works now. I get the time the player spent on the platform, so thank you.

But timers still does not still seem to actually work.

I’m glad you got your blueprint working, though sorry for the confusion about the timers. Timers are actually a mechanism used to call a function you specify after a certain amount of time, not necessarily as a means of counting time like a stopwatch. When you use “SetTimer,” you’re specifying which function should be called and when (how many seconds from when the timer is set). As you said, any action connected to a “SetTimer” will execute immediately right afterwards, as the “SetTimer” node is only setting up a function to be called later. As a simple example, in the following two screenshots (I just threw these together at home, so they’re not great :p), I set a timer to call a new function I added, “MyTimerFunction,” in 10 seconds. When I start the level, it immediately prints “I just set my timer!” and then 10 seconds later, prints “Timer executed!”