Need algorithm for private variables and transitions

This forum is currently in read-only mode.
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Alright, so I'm trying to come up with my own algorithm for constantly obtaining the X and Y positions of my NPCs using private variables. But before I would put it all into events, I need to ask if is possible.

    Since there will be a time where the player will leave the layout, and would eventually come back. What I need is for the game to record each NPCs current X and Y pos the moment the player left the layout, and when he gets back, it will just load it up and will cause the NPCs to be recreated at the same positions they were when the player left the layout.

    So how would I do that?

    Another is how do I play a transition that will only cause the player to transfer to a different position, not layout? I was thinking that if the player goes out of the house, there will be a small transition, like the circle and will cause the screen to go black, then will fade and at the moment, the player will already be outside of the house.

    How do I do that? Helps will be much appreciated.

  • For your first question. You can do it a number of ways.

    I'm not sure if making the NPC's global will keep their values or not, but if it does you could just go:

    start of level: set NPC position to VariableX and VariableY.

    Or you could store the info in global values, or save them in an external file or what ever. Then just set the positions at the start.

  • Hmmm... But I will be having like around 50 or so NPCs in one layout since that layout will more likely be a town or city map. Would that mean 50+ global variables?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use a Hash Table to keep track of your town. When the player leaves, cycle through each townie with a loop and record their X/Y in the Hash Table. When the town loads, cycle through the table and create each townie in the X/Y that is stored in the table.

    You could give each townie a PV for it's index in the Hash Table, essentially naming them 1 through 50, so it would be easier to loop them.

    You could even keep track of other things for your townies, like what conversation they've already had or whatever... anything that needs to be global. Then you just make your Hash Table global, and your townies won't need to be global.

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