Recording a Characters movements and actions to apply to a "Ghost" in the future.

Hi. i’m creating a game where i’m needing to record a players actions and then later a “Ghost” of sorts will mimic those actions. If you don’t what i’m trying to accomplish then think about time trials in Mario Kart how they have a ghost cart that races against you that is actually the racer who has the fastest time.
video reference —>[video][/video]

I managed to do what i wanted. all actions of a player were recorded every tick and then i could apply that to a new character. But it only works well in single player. in multiplayer it causes the players movement to be very jumpy for the which i think is due to the data that is being recorded every tick. what I think is happening is that their is just too many processes that are having to be done each tick and sent over the server and its just causing everything to be very laggy. does anyone know a better way to do this that would be more cost effective?

Here is my blueprint. this is running every tick.
Record Actions.png

EDIT: Just to clarify. it is the actual players character that is lagging when the recording is happening. not a ghost.

Looks like you need to add interpolation based on your history stored to avoid lag.

I am not familiar with interpolation. how could I use that in recording actions?

It’s explained here :

Only ideas on the fly :
For an a.i you may can use a random stream for all your random choices and set it again to have same choices done
For a player, you may save only actions with a save added on events and when mouse current move is modified only, this would reduce significantly the lag as no more tick.

I think I understand how interpolation works, but I just don’t see how that will help in my case. because I move the character with a character movement component. so why would I apply interpolation to that? are you talking about interpolation between each tick of my recordings? I’m not applying any records to a character that is being controlled. I just record the data each tick. the data stored will be applied to a Ghost later. I feel like maybe im not explaining my system properly or maybe i’m just not understanding what you are trying to tell me.

right now i have it to set up to record every tick. so that if the player doesn’t take an action for a tick, the system records that. so lets say I decide to record only when an action(move/shoot/jump) is being taken and record it into and array. when i try to apply that array of action to the ghost i wont be able to do it by tick. because the actions weren’t recorded every tick. Idk how i could get the timing down.

Maybe only save a tick count on tick when starting recording and add this value with saved actions like a time code.

ill try this and get back to you guys.

Sorry its been so long everyone. I figured out how I could do this. I saved the first Delta Seconds from event tick into a variable and then set a timer to run a function that records all of the information I needed and for it to loop every Delta Seconds. it worked very well. Ill provide my blueprint on request if anyone needs it.

Thanks to everyone that helped me out!


requesting (2)

Requesting! :slight_smile:

I would like to request this too. It sounds interesting.

Hi, I know this is pretty old but in hopes OP is still active, could I request the blueprint? Pretty please :slight_smile:

I’m also requesting more info an updates about this but it’s seems I’m late.

Same here - OP is it possible to obtain a blueprint? Thanks in advance !

I haven’t used it yet so I don’t know how well it works or even if it would work for your needs, but take a look at the UE4 Builtin Replay System:

I made something like that for my project a while ago, it takes the current time and the transform and adds it to an array. I have no idea if there is a better way of doing it but for me, it works.
all you have to do is to add the module to your character and then use it as a reference and search for “Recording” this should give you a few custom events with which you can toggle, replay and save the recording. of course, you are free to make any changes to it.


preview: BotRecorder animated gif

I’ve been struggling with that type of code for a while, I manage to make it work several times but it always was framerate dependent.
so what I’m basically doing is getting the current “Get game time in seconds” to generate an index for my array, that was the only way I was able to get it frame rate independent.
there are still some issues with the code for example right now I’m recording in 30fps but as soon as the game runs lower than that the recording will stop.

here is a pic of the code if download link is too suspicious for you :smiley: