Michał Wróblewski
Michał Wróblewski
Created by Michał Wróblewski on 4/15/2024 in #💾sample-code
How to record sessions with RealtimeSessionCapture
⚠️ DISCLAIMER: This API will be removed in some upcoming release (probably 3.0). The whole solution (for simplicity reasons) is best to be implemented on the server side. Anyway, if any of you really need to try it, feel free to go.
⚠️ DISCLAIMER 2: The sample code provided is simple enough for you to integrate with your case and way to launch recording. Basically it records when room connects or script is enabled. Stops capture when the script is disabled or room disconnects. More important are the troubleshooting steps.
What do I need it for? In the world of multiplayer games, testable use cases, preview of data in hand, easily check how given sequence behaves from 3rd players perspective is golden. When you record a part of gameplay you should be able to play it back over and over. And session capture is done in the most universal way possible - stream of data from the server and you have a test case in a form of a recording file. Of course it's not that perfect because data can become invalid or miss some new data. Then you need to record this case again. RealtimeSessionCapture is a script bundled with Normcore for you to be able record local player's data. So far I noticed it's not so easy to setup, even for one player (or especially). As mentioned above, expect it to be deprecated and removed. Basically if you have 2 players and record their sessions with RealtimeSessionCapture in Record mode to playback you just need to place 2 recording files in Playback Capture Files list and change mode to Playback. I noticed order of files matters. The first file is always primary and other ones are secondary. Order of files can be a source of problems. In case you only want to record a local player when you provide the recorded file for playback, you may encounter errors like Realtime: Timeout while attempting to connect scene views. It means that recording file misses initial recording of a scene view - usually when you connect to a non-existing empty room. To record: Add RealtimeSessionCapture, set mode to Record, add RealtimeSessionCaptureDouble and enable the script. When you run and connect to a room it will start recording. Disconnect to stop recording. If you have more players and what their stream (unreliable) recorded you need to record on all players, that's the clunky part in the workflow. To playback. Disable or remove RealtimeSessionCaptureDouble, change mode to Playback, fill paths to 2 files that were recorded, they are saved in your Documents folder under Normal/SessionCapture, you can use paths relative to your project root, Make sure the *_double.realtime recording is first (primary). GIST: https://gist.github.com/vrobel/7af0e513e06a969bd6ef4f157a9994c3
1 replies