How do I Keep Player Position When Changing Layouts

1 favourites
  • 5 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Sorry if this has been asked and answered somewhere else but I really don't even know how to search for my answer. I am not sure what you would call the thing I am trying to do but I can relate it to something like Pokemon. In Pokemon you have a player controlled character that moves across a tiled open world map. Occasionally if you step on a specific tile it will do a sort of layout change to take you to a battle sequence. Once you have completed the battle sequence it will change back to the previous "layout" of the open world, now here is where I am having a problem, right on the tile you were before the battle. So I made a little demonstration to try and figure this out and here is what I have.

    In layout1 we have the player(red box), two planets(blue and green dots), and two triggers(red dots inside "planets"). I currently have the events setup so that if the player collides with either trigger it will switch to layout2 or layout3 depending on the trigger.

    In layout2 we have the player again and another trigger(this time a black dot). For the events on this one I have it so that if the player collides with the trigger here it will return to layout1.

    So now onto my problem. I want this setup to place my player back at the planet it came in from when it leaves layout2 or layout3 and transitions back to layout1. In layout1 the player spwans into the game in the top left quadrant. If I were to go down to the green planet and transition into layout2 and then touch the black spot to transition back to layout1 I am now back at the top left quadrant instead of on top of the green planet. I am racking my brain but cannot think of any way to do this without doing a save/load sequence that would save the game right as the player touches a planet and then loads back to that save when they touch the black dot, essentially ignoring the progress made on layout2 or layout3 when returning to layout1.

    Phew, sorry for the long read but any help with this will be greatly appreciated. Also I only just started working with Construct 2 today so I may need some extra simple instructions.

  • Using the global variable to save the coordinates before changing the layout.

    In the next layout, the player coordinates are load from the global variable.

  • Beautiful, that works perfectly and is really easy to set up. Thank you very much for the help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Looking at this as a possible fix for a problem I am having... Question: does each layout have to have it own event sheet for this to work?

    Answer to my own question: it would appear so.

  • This makes so much sense after being told. Thanks a bunch. This same issue was bothering a few weeks ago when I was playing around with different game types.

    Aaron

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