playMaker

Author Topic: Set position according to previous scene  (Read 271 times)

BDSmith62

  • Playmaker Newbie
  • *
  • Posts: 1
Set position according to previous scene
« on: March 26, 2023, 09:58:55 AM »
Hey all,

Have had PM for a while. Never used it. Slowly starting to.

I'm building a game in which there will be a "main hub scene" think of it like the Field in Zelda: OOT. You can access many different levels from that area.

So. The player start in another scene "Home" for the tutorial. After which, the character will be able to progress into the "field" (hub) area to progress.

My lack of knowledge is; how to I set the characters position in the "field" area based on where the player came from?

i.e; If he comes from the home area, he needs his position set to the field entrance that corresponds to having just left home. (where if you turn around you'd reload the home scene).

Can't seem to find a tutorial that specific. Just basic linear scene changes with 1 spawn point.

Update: Will eventually need to be able to transfer player inventory/ equipped items...
« Last Edit: March 26, 2023, 10:46:21 AM by BDSmith62 »

curb47

  • Sr. Member
  • ****
  • Posts: 256
Re: Set position according to previous scene
« Reply #1 on: March 30, 2023, 12:32:35 PM »
If you're transferring data from one scene to another, you'll want to set up a  GameManager Object/Singleton.

This object is not destroyed when you switch from one scene to another, so, when you exit one scene you can save as many variables to it as you like, and then when you load the new scene, you get those variables and transfer the values to the objects in the new scene you just loaded.

If you're building a game with multiple scenes/levels, a GameManager object is essential.

This video is very old, but the core principals haven't changed...