Recording player movement and saving it in a Datastore

Hey there! I’ve been playing around with the idea of developing a simple demo recording module for some duel game. The idea, basically, is that this script would record both players’ movements and attacks and save them, possibly in a DataStore, for others to review at a later date.

The problem I have is that a match can last up to 10 minutes, and if I want to record this at 60 frames per second, that would mean up to 36000 frames for one game. Since the DataStore limit is at 260k characters, I won’t even have room for 8 characters of info to save in each frame.

I’ve been thinking of cutting out every other frame and interpolating, as well as only saving the CFrame of the player’s primaryPart and their current animation frame, rather than every part’s CFrame. I’m afraid that I wouldn’t be able to properly reproduce the player’s movement by saving only their input. I could also use several datastores if needed but I don’t know if that would be the cleanest solution.

In short, my current worry is essentially the size constraint, since datastores usually aren’t used to save that type of data. Do you have any recommendations as to what I could do to alleviate that size limit issue? Is there a similar module out there that found an interesting workaround? Thanks for your help.

2 Likes

I feel like what you can do is as the match plays out, you would have 2 tables one logging animation frames as well as one logging cframe values, after the fight, then you would have 2 datastores and saving them separately since this would lower the character count by half (assuming the animation keyframe’s are in CFrame). What you then could do is lower to 30 frames per second. Also you would have a separate datastore for the attacks as well.

This is just a suggestion, I personally think 60 frames is unnecessary to reproduce a scene, 30 frames should be able to capture the movements of the surrounding unless projectiles or parts are moving at high velocity.

I hope you the best of luck with your recording module it seems very interesting.

1 Like

In short, I think you’re trying to make a replay system. On a quick search, I found this YouTube video which may/may not be helpful to you: https://www.youtube.com/watch?v=vJnMO4IEgoE.

1 Like

You could store the match using many keys (one key per 30 seconds or something like that, maybe an even smaller time slice than that). If the match is 10 minutes long anyways that’s plenty of time to get the separate keys without having any playback hiccups.

Thanks, I actually hadn’t thought about the fact that I could keep loading parts of the replay while the previous parts are playing. I’m probably gonna use something like that.

I’ll be sure to look into the code of that module. Thanks a lot!

I’d simply like to add that I stumbled on this module which proves particularly helpful in my case, where a lot of repetitive characters appear in a table definition ( {}":[] ). In some cases, a sample of 7000 characters was reduced to fewer than 2000 in pretty much no time at all. Pairing this with stravant’s proposed method of slicing the data into different key,value pairs should alleviate the size limit problem completely.