I'm a doctor, not a mechanic
Difference between revisions of "Timing"
m (→SetTimer) |
(→How to make seconds real) |
||
Line 115: | Line 115: | ||
* <code>inObj</code> - object for accessing function name. | * <code>inObj</code> - object for accessing function name. | ||
− | == | + | == Time Dilation == |
− | + | WorldInfo object includes a <code>TimeDilation</code> property. The correct way to access it from UnrealScript is to use <code>SetGameSpeed</code> function defined in <code>GameInfo</code>. This property can also be manipulated with <code>slomo</code> cheat command. | |
− | + | ||
+ | The more dilation is, the faster game is. For instance, if <code>TimeDilation</code> was 2.0, the game would be twice as fast. It means that each real world second would correspond to two in-game ones. A timer with rate 1.0 would be called each gameplay second. But a timer with rate <code>WorldInfo.TimeDilation</code> would be called once per '''real''' second. | ||
+ | |||
+ | In PC version of UT3 there's additional multiplier equal to 1.1. That is, default time dilation is 1.1. <code>SetGameSpeed</code> honors this multiplier (in fact, this multiplier is defined there). | ||
== See also == | == See also == | ||
* [[UE3:Actor native functions (UT3)#SetTimer | SetTimer in UT3]] | * [[UE3:Actor native functions (UT3)#SetTimer | SetTimer in UT3]] | ||
* [[UE3:Actor native functions (UDK)#SetTimer | SetTimer in UDK]] | * [[UE3:Actor native functions (UDK)#SetTimer | SetTimer in UDK]] |
Revision as of 09:54, 4 November 2011
This article is a stub. You can help Unreal Wiki by expanding it. |
Timing is a family of functions using which you can schedule other functions to be called asynchronously at a interval. Only SetTimer
exists in UT2004. Like in JavaScript, despite asynchronous nature of SetTimer, UnrealScript is still single-threaded. It means that you don't have to worry about thread-safety. Race conditions are still possible though.
Contents
Functions
SetTimer
native final function SetTimer( float inRate, optional bool inbLoop=false, // not optional in UT2004 optional Name inTimerFunc='Timer', // doesn't exist in UT2004 optional Object inObj // doesn't exist in UT2004 );
Sets a timer to call the given function at a set interval. Defaults to calling the 'Timer' event if no function is specified. If inRate is set to 0.f it will effectively disable the previous timer.
inRate
- time interval, in gameplay seconds. IfinRate <= 0.0
, it'll reset the timer.inbLoop
- if false, it'll fire only once. Default to false.inTimerFunc
- function name.inObj
- object whose function will called. Defaults toself
. Note that timer is still registered onself
object, not oninObj
. Which means, for instance, it's pointless to write something likeSetTimer(1.0,,, OtherObj); Destroy();
ClearTimer
native final function ClearTimer( optional Name inTimerFunc='Timer', optional Object inObj );
Clears a previously set timer.
inTimerFunc
- function name.inObj
- object whose timers will be cleared.
ClearAllTimers
native final function ClearAllTimers( optional Object inObj );
Clears all timers for the given object.
inObj
- object whose timers will be cleared.
PauseTimer
native final function PauseTimer( bool bPause, optional Name inTimerFunc='Timer', optional Object inObj );
param
inTimerFunc
- function name.inObj
- object whose timer will be paused.
IsTimerActive
native final function bool IsTimerActive( optional Name inTimerFunc='Timer', optional Object inObj );
Checks is specified timer is active.
inTimerFunc
- function name.inObj
- object whose function will be called.
GetTimerCount
native final function float GetTimerCount( optional Name inTimerFunc='Timer', optional Object inObj );
Gets the current count for the specified timer, defaults to 'Timer' if no function is specified. Returns -1.f if the timer is not currently active. See GetTimerRate
below for explanation.
inTimerFunc
- function name.inObj
- object whose function will be called.
GetTimerRate
native final function float GetTimerRate( optional name TimerFuncName = 'Timer', optional Object inObj );
Gets the current rate for the specified timer. GetTimerRate('SomeTimer') - GetTimerCount('SomeTimer')
is the time remaining before 'SomeTimer' is called. In other words, "count" starts at 0, increases, and when it reaches "rate", timer is fired.
inTimerFunc
- function name.inObj
- object whose function will be called.
ModifyTimerTimeDilation
native final function ModifyTimerTimeDilation( const name TimerName, const float InTimerTimeDilation, optional Object inObj );
This will search the Timers on this actor and set the passed in TimerTimeDilation
inTimerFunc
- function name.InTimerTimeDilation
- new time dilation for this timer function.inObj
- object whose function will be called.
ResetTimerTimeDilation
native final function ResetTimerTimeDilation( const name TimerName, optional Object inObj );
This will search the Timers on this actor and reset the TimerTimeDilation to 1.0f
inTimerFunc
- function name.inObj
- object for accessing function name.
Time Dilation
WorldInfo object includes a TimeDilation
property. The correct way to access it from UnrealScript is to use SetGameSpeed
function defined in GameInfo
. This property can also be manipulated with slomo
cheat command.
The more dilation is, the faster game is. For instance, if TimeDilation
was 2.0, the game would be twice as fast. It means that each real world second would correspond to two in-game ones. A timer with rate 1.0 would be called each gameplay second. But a timer with rate WorldInfo.TimeDilation
would be called once per real second.
In PC version of UT3 there's additional multiplier equal to 1.1. That is, default time dilation is 1.1. SetGameSpeed
honors this multiplier (in fact, this multiplier is defined there).