I there a way to record player input and play it back once the game has stopped?
I understand that this is a very awkwardly phrased question but what i am trying to ask is if there is a way to record what i input into the game ( such as if i press play and press jump) that I can unplay and make a gameObject do that action or, possible more, actions. I will try to explain more if I am not clear
Answer by Dibbie · Feb 03, 2016 at 07:31 AM
I dont fully understand what your trying to do, why you would want to track if a person jumped in your example, but if you simply mean to just have a way to store data on the user, like a "save game" almost, you could look into something called PlayerPrefs. There actually pretty simple to use.
This information is kept after the game ends, if you dont delete the Key afterwards. I have no idea where its saving this information to, but its kept with the game after you finish playing your game.
Usage Example:
//C#
int jumps = 0;
if(Input.GetKeyDown(KeyCode.Space)){
//if the user presses the spacebar key
jumps++;
PlayerPrefs.SetInt("jumpCount",jumps);
}
if(Input.GetKeyUp(KeyCode.Space)){
//After the use presses the spacebar key, show them their stored jump count
print(PlayerPrefs.GetInt("jumpCount");
}
On Windows PlayerPrefs are stored in the registry, so they're actually separate from the game although they do stick around.
Ah ok, thats interesting, I didnt know that it works specifically in that way, thanks for the added information.
Answer by itsharshdeep · Feb 03, 2016 at 08:01 AM
You can also save the the list of the actions in the list (or something) which player has performed. Then call that event manually ..
Like player has input Right turn > Jump > Left turn > Slide and then he dies.
Suppose, you want to show the replay or you want to show the bot ( dummy player to demonstrate what the heck you have done) .
Now the events you have tracked ( lets say in 'PlayerTrackerList' ) , call manually each event with the exact time interval to demonstrate the same actions that user has done ..
*Note :- This is theoretical definition or approach. It may be vary upon the project requirements.
May be someone even more better approach.
Your answer
Follow this Question
Related Questions
SteamVR Beta Input Action Issue 1 Answer
problem when using 2 actions map in new Input system. 0 Answers
Syntax for accessing a certain Input Actions' properties via script... 0 Answers
Saving player input and playing them mirrored 0 Answers
New Input System only sometimes registering release of key 0 Answers