# aego/time

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

`Delta` and `Elapsed` count game time, which follows the time scale and stops while paused; `Unscaled` and `UnscaledElapsed` count real time. `SetPaused` and `SetScale` change the clock of a running game; the documentation sandbox has no world clock, so calling them there stops the script, and the example only reads the clock. See [Time](/time.md).

## Example

```aes run
package demo

import (
    "aego/log"
    "aego/math"
    "aego/time"
)

script Bob {
    @export var Amplitude float = 0.5

    func Update(dt float) {
        y := math.Sin(time.Elapsed() * 3) * Amplitude
        node.SetPosition(Vec2{0, y})
        if time.Frame() % 30 == 0 {
            log.Info("frame " + string(time.Frame()) + ", elapsed " + string(time.Elapsed()) + " s, delta " + string(time.Delta()))
        }
        if time.Frame() == 60 {
            log.Info("scale " + string(time.Scale()) + ", paused " + string(time.IsPaused()) + ", fixed step " + string(time.Fixed()))
            log.Info("real time since start " + string(time.UnscaledElapsed()) + " s")
        }
    }
}
```

## Delta

```
func Delta() float
```

Returns the game seconds since the previous frame: real time × Scale, 0 while paused. Inside FixedUpdate it is the fixed step.

## Elapsed

```
func Elapsed() float
```

Returns the game seconds since Play started. It stops while paused and follows Scale.

## Fixed

```
func Fixed() float
```

Returns the fixed step length in seconds, 1/60 by default. Scale does not change it; it changes how many steps run.

## Frame

```
func Frame() int
```

Returns the number of frames this world has run, paused frames included.

## IsPaused

```
func IsPaused() bool
```

Reports whether game time is paused.

## Scale

```
func Scale() float
```

Returns the time scale: 1 is normal speed, 0.5 is half speed, 0 freezes game time without pausing.

## SetPaused

```
func SetPaused(paused bool)
```

Pauses or resumes game time. While paused, Update, FixedUpdate and game-time coroutines of ordinary scripts do not run.

## SetScale

```
func SetScale(scale float)
```

Sets the time scale from 0 to 8. The fixed step stays the same, so the simulation stays stable; only the number of steps changes.

## Tick

```
func Tick() int
```

Returns the number of the current or last fixed step. It is the same number the profiler and the Event Monitor show.

## Unscaled

```
func Unscaled() float
```

Returns the real seconds since the previous frame, ignoring Scale and pause.

## UnscaledElapsed

```
func UnscaledElapsed() float
```

Returns the real seconds since Play started, pauses included.
