Index | Collapse All Expand All

GetGameTime Method
Engine Class Members Examples See Also

Beta Documentation - Subject to change.
Gets the current relative game time.

# Syntax

Lua
    function Engine.GetGameTime();

#### Returns

Type: number
Returns a relative game time in seconds.

# Remarks

Gets the current game time as a relative value that can be used for delta time processing.

# Examples

This example demonstrates using GetGameTime to calculate the delta time over multiple updates for performing animations.

Calculating Delta Time | Copy Code
--- | ---
            local currentGameTime = Turbine.Engine.GetGameTime();
            local delta = currentGameTime - previousGameTime;
            previousGameTime = currentGameTime;

            -- Performing a translation from one position to another over a 5
            -- second period.
            self:SetLeft( self.startLeft + ( self.endLeft - self.StartLeft ) * ( delta / 5 ) );

# See Also

- Engine
- Turbine