Tickers in UnrealScript
Tickers are used when you want to do something repeatedly at regular intervals. Here’s an example of a ticker that ticks periodically until we stop it.
In UnrealScript, we use the SetTimer
function to create a repeating timer that acts as our ticker. The Tick
function is called every 500 milliseconds (0.5 seconds).
We set another timer to stop the ticker after 1.6 seconds, simulating the behavior of the original example.
The bShouldStop
variable is used to control when the ticker should stop. When StopTicker
is called, it sets this flag to true and clears the timer.
When we run this script, the ticker should tick 3 times before we stop it.
Note that UnrealScript doesn’t have built-in concurrency like goroutines, so we’ve adapted the example to use UnrealScript’s timer system. The WorldInfo.TimeSeconds
is used to get the current game time for logging purposes.
This example demonstrates how to create a repeating timer in UnrealScript and how to stop it after a certain duration.