How do I save/store player inputs?

0 favourites
  • 4 posts
From the Asset Store
Supports keyboard, mouse and gamepads. Supports several gamepads at once.
  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

    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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)