Delta Time Patch

The Delta Time patch returns the time interval between the last frame and the current frame in seconds.

You can use the returned delta time value to create animations which are decoupled from the frame rate, resulting in smooth transitions and consistent results regardless of frame rate changes. This is particularly important in ensuring that AR games work consistently across different devices.

For example, to animate an object’s position over time, you could use the following formula:

  • position = (position + velocity) * deltaTime




Delta time

Returns the time interval between the last frame and the current frame in seconds.

Animating an object

In this example below, the 3D object is animated along a horizontal plane. The animation speed is independent of the frame rate.

The 3D object will move across the scene at a consistent speed on a range of different devices:

Animating an object along a forward vector

The patch group below moves an object along its forward vector at a consistent speed using the Delta Time and Rotate Vector patches.

The 3D object can be seen moving across the scene:


Equivalent functionality can be achieved in a script with the deltaTimeMS property, which is exposed by the Time module

const Scene = require('Scene');
const Reactive = require('Reactive');
// Time module containing deltaTimeMS property
const Time = require('Time');

(async function () {

    // To access scene objects
    const [cube] = await Promise.all([

    const vector = Reactive.vector(0, 0, -1);
    const rotatedVector = vector.rotate(cube.transform.rotation);
    const velocity = Time.deltaTimeMS.div(1000).mul(rotatedVector);
    cube.transform.position = cube.transform.position.history(1).frame(-1).add(velocity);


Unlike the Delta Time patch which outputs the time value in seconds, the deltaTimeMS property returns a time value in milliseconds for consistency with the rest of the Spark API.