Is there a way to implement a ghost mode where a ghost can replay the best possible solution of a set of data?
My idea is that my 2D platformer game has obstacles in it and a player has to navigate it through obstacles after a few tries to get a set of input data.
So then, I can tell it to change to 'ghost' mode whereby i cant press anything but a ghost will substitute me based on my previous tries and gets an efficient route.
An example of a controller to store keypresses would look something like this.. actions[0].milliseconds = 400 actions[0].action = right pressed actions[1].milliseconds = 1000 actions[1].action = jump pressed actions[2].milliseconds = 1300 actions[2].action = jump released actions[3].milliseconds = 2500 actions[3].action = jump pressed actions[4].milliseconds = 3000 actions[4].action = jump released actions[5].milliseconds = 5330 actions[5].action = right released
..but I have no idea on how to pass this to the 'ghost' character.
I would plan it out like this - Have a player go through the game a few times to get input data - Allow the player to tell the current Active Character to enter Ghost mode. - Reset the Character. This will place them back at the starting position. They will in turn tell their Controllers to reset to millisecond 0 with no keys pressed. - And from here the ghost will show how the player behaves
This is something you need to simply try. Search "unity ghost car" in google for examples.
I'm not sure I understand what you need. It looks like you already have an array of actions, are you unsure how to pass that array to your ghost class? I would assume the ghost class has a place to store the action array, why can't you simply assign it to that member, when you instantiate/switch to the ghost driver? Or, are you trying to figure out how to store the actions and times into the array, in the first place?
Yes, I am unsure how it is to pass it to the ghost class or rather the algorithm that is needed to make sure the ghost class can replace the current active character
Your answer
Follow this Question
Related Questions
How to automatic reference another GameObject Transform? 1 Answer
Help with 2D AI scripting 0 Answers
A* Pathfinding and keep the enmy at range 0 Answers
Ally AI shoot arrow 0 Answers
Enemy character floats while he moves back and forth 0 Answers