const CLIP_URL = "atp:3fbe82f2153c443f12f9a2b14ce2d7fa2fff81977263746d9e0885ea5aabed62.hfr"; const RECORDING_CHANNEL = 'PlayBackOnAssignment'; const RECORDING_CHANNEL_MESSAGE = 'BowShootingGameWelcome'; // For each different assignment add a different message here. const PLAY_FROM_CURRENT_LOCATION = true; const USE_DISPLAY_NAME = true; const USE_ATTACHMENTS = true; const USE_AVATAR_MODEL = true; const AUDIO_OFFSET = 0.0; const STARTING_TIME = 0.0; const COOLDOWN_PERIOD = 0; // The period in ms that no animations can be played after one has been played already var isPlaying = false; var isPlayable = true; var playRecording = function () { if (!isPlayable || isPlaying) { return; } Agent.isAvatar = true; Recording.setPlayFromCurrentLocation(PLAY_FROM_CURRENT_LOCATION); Recording.setPlayerUseDisplayName(USE_DISPLAY_NAME); Recording.setPlayerUseAttachments(USE_ATTACHMENTS); Recording.setPlayerUseHeadModel(false); Recording.setPlayerUseSkeletonModel(USE_AVATAR_MODEL); Recording.setPlayerLoop(false); Recording.setPlayerTime(STARTING_TIME); Recording.setPlayerAudioOffset(AUDIO_OFFSET); Recording.loadRecording(CLIP_URL); Recording.startPlaying(); isPlaying = true; isPlayable = false; // Set this true again after the cooldown period }; Script.update.connect(function (deltaTime) { if (isPlaying && !Recording.isPlaying()) { print('Reached the end of the recording. Resetting.'); isPlaying = false; Agent.isAvatar = false; if (COOLDOWN_PERIOD === 0) { isPlayable = true; return; } Script.setTimeout(function () { isPlayable; }, COOLDOWN_PERIOD); } }); Messages.subscribe(RECORDING_CHANNEL); Messages.messageReceived.connect(function (channel, message, senderID) { print('channel: ' + channel); print('message: ' + message); if (channel === RECORDING_CHANNEL && message === RECORDING_CHANNEL_MESSAGE) { playRecording(); } }); //Messages.sendMessage('PlayBackOnAssignment', 'BowShootingGameExplaination');