Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | MrKrakens | |
Old Version | Published before Godot 3 was released. |
Hello everyone! Just thought I’d think out loud and ask a question.
Right now I have a platformer game and I want to implement a “ghost” character that can replay the player’s previous runs.
I haven’t implemented this yet but I was thinking of having a struct like dictionary with arrays inside? :
var prev_run_player_movements = {
x_pos = [],
y_pos = [],
grav = [],
velocity = []
}
Then throughout the game until the player dies I would add to the array’s the player’s x,y positions
Then when replaying the previous run, I would just iterate through prev_run_player_movements changing the player object’s x y pos to the held values.
But how would I also save the player’s animations too?
I have a state system (consts from 0 to 4) set up that checks if the player is moving or hit… so maybe instead of recording the exact movements, record at what time (real time value) each state was executed at?
var prev_run_player_movements = {
recorded_state = [],
at_recorded_time = []
}
then iterate through that? As I type that actually seems way more logical. I guess the dictionary seems redundant when I could just have the arrays instead.
Thoughts?