Skip to content

Replays

Replays can be controlled from within camera scripts. This gives camera scripts the ability to be designed around a particular replay, with precise animations or depth of field effects to match the players in the replay.

Usage

Loading Replays

To load a replay file, call Replay.load("replay_filename.a2replay"). This will add the replay file to the list of loaded replays. Replays can only be loaded from the standard replays directory, which is ~/Documents/Another-Axiom/A2/Replays/.

Controlling Playback

Replays playback can be controlled with the following functions:

  • Setting isPlaying to cause the replay to advance automatically.
  • Calling setPlaybackTimestamp() to set a timestamp at which the replay was recorded.
  • Calling setPlaybackTimeSeconds() to set the time in seconds from the beginning of the replay. This ranges from 0 to the replay duration.

Loaded replays will always show their current playback position, but you can also get the frame data from multiple frames at once for analysis purposes.

Examples

Drawing a Point Cloud

This example loads a replay and draws a point cloud of player head positions at a 5Hz sampling rate. It then unloads the replay.

local replayName = "example_replay.a2replay"

World.clear()
local points = 0
local replay = Replay.load(replayName)
local resolution = 5 -- how many times per second to sample
-- Loop through the replay at the sampling interval
for i = 1, replay:getDurationSeconds() * resolution do
    -- Get the frame data at the current time
    local frame = replay:getFrameAtTimeSeconds((i - 1) / resolution)
    -- For each player, draw a point at their head position
    for j = 1, #frame.players do
        local player = frame.players[j]
        World.drawPoint(player.head.position, 1, 0, 0, 6, 0)
        points += 1
    end
end
print("Total points drawn: " .. points)
Replay.unloadByIndex(#Replay.listLoaded())