How do I get my player to the same place as before?

0 favourites
  • 8 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • So I have this following setup. I got 4 layouts, which two of them are used for my menu,. The other two are the main layout (where the main game occurs) and a house layout (which is like a house that holds a npc inside). But the thing is, when I get inside the house and leave it, I return to the start of the main layout again, and not on the location i was before. Is there any way i can fix this in order to make the player return to the place where i was before (in this case near the door of the house, where i entered)?

  • Try to set your object to Global, so it won't be destroyed when you switch layouts.

    More info here :

    Common instance properties

  • Try to set your object to Global, so it won't be destroyed when you switch layouts.

    More info here :

    https://www.scirra.com/manual/71/instances Common instance properties

    I have tried by setting it Global but when I return to main Layout he doesn't appear. But I'll try to check with the guide you gave for better informations, so thanks anyway

  • Set a few instance variables in your player's controller sprite (or, if player isn't global, in an invisible global sprite's instance variable or even a global variable). Name them something like "StartX" and "StartY". Set them as numeric and make them static (static is only important for local and instance variables, not for global). When you leave a layout, set the variables to the x and y (respectively) of the spot you want them to enter the next layout at. You can do this just before the "go to layout" action. Then, on the layout start, make the player's x and y = the variables StartX and StartY values. This way, you can start anywhere you want from any layout, including your menu. It's like creating a landing pad.

  • There's a behavior called "Persist." Just give it to everything you need the game not to reset. When you actually want to reset the game, like when the player dies, add the action "System -> Reset Persisted Objects" in your events.

  • This is good for quick games, but for longer games, sometimes you need more control over individual items. Imagine Samus in Super Metroid. We want her position to persist, the enemies to reset, and the powerups remain collected (persist). Otherwise a missile or energy tank could be re-collected every time the area's persistence was reset. It's also a bit easier to track when you have a boatloat of objects. Persist and reset persisted objects are still very important, but there are occasions when the extra control is essential.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I was battling the same problem with certain layout that didn't need things on layout so I had to dump all my Ui icon ish on a family and just made them invisble not destroyed just not seen and made sure that the event sheet for the UI was never used. And I even had to disable the movement control on player.

    It does work just that its very annoying wished that there as an ability to choose which layout to be persist for and which layout to never appear.

  • Davemon Ok but how can I set, on start of layout, my PlayerX coordinates to StartX varibable (the same for the Y coordinate)?

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