This is an old unanswered question. Im currently working on a fake adaptive ai system and i would like to try this approach. tracking the player movement based on coordinates doesnt work since the enemies need to perform the new "learnt" movement in different locations. Does anyone know how store these inputs? Thanks!
Develop games in your browser. Powerful, performant & highly capable.
To store inputs, you would push each input into an array as you enter them. The format is up to you, as well as what to do with the history of inputs after you have them stored.
I had an old example that stored coordinates here. dropbox.com/s/1vi6kp5p7lcn30n/undo_example.c3p
I know you said coordinates won't work for your system, but the idea is the same. Instead of storing the coordinates, you would store the key pressed instead.
Sounds like you already tried storing the coordinates and they seem to not be useful, but you can make them useful.
Try turning the absolute coordinates into relative coordinates, that way you will be able to use them for different instances.
After you store all the player positions into an array, you can then create a new array with the corresponding relative coordinates.
The first element of the relatives coordinates array will be 0,0 because that is the starting position. Each subsequent element is the difference between itself and the previous element.
absolute coordinates: 100;100, 200;100, 300;300, 400;500
relative coordinates: 0;0, (200-100);(100-100), (300-200);(300-100), (400-300);(500-300)
You can then use the relative coordinates to tell any instance to follow the same path but from their own position. So the first place is 0;0, so they stay in place, then you add the following offset to your current position. You continue moving by the offsets until you reach the end.
Thank you for your suggestions. I like the the idea of converting the coordinates rather than capture the inputs, its a very clever solution and I will definitely give it a try. back with an update as soon as I get things working.