playMaker

Author Topic: Load level and spawnpoints  (Read 731 times)

nickg84

  • Playmaker Newbie
  • *
  • Posts: 7
Load level and spawnpoints
« on: September 13, 2021, 10:04:23 PM »
Hi everyone,

Very new to Unity and PlayMaker, but I'm learning a lot!  One thing I just started experimenting with is loading the player between scenes.  For example, I've got an exterior house with a front door and back door - scene 1.  I've got the interior of the house with a front and back door - scene 2.

I can set up the interactions fine, but in the simplest way possible, how do I load the player into the new scene (and vise versa) and set the exact position/rotation points?  So if they enter the front door, they should appear inside the house at the front door, then exit the same way.

I also have a Don't Destroy GameObject component on the Player, I'm guessing this is the best way to load the player between scenes (retaining health, etc)?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Load level and spawnpoints
« Reply #1 on: September 14, 2021, 07:10:36 AM »
Hi.
In our game i use a fsm that handles loading scenes. and i have this as a global variable and not destroyed.

in the scene handler i us a Int Variable which i use to go to position on the new loaded scene.

on the (world) scenes i have a fsm that gets that Int Variable  and looks into an array where it should move the player.
then moves the player to that position and sends a event to the loading fsm that it is ready.

i also use the loading fsm to show/hide loading screen and some other stuff.

nickg84

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Load level and spawnpoints
« Reply #2 on: September 14, 2021, 03:04:40 PM »
Thank you for the response.  I think I'm following, but am probably missing a few steps.  What I have set up currently is a trigger on a door that goes through the motions, then ends with "Load Scene At Spawnpoint".  The scene name is set (and works correctly), and I have a global variable here as the spawn point.  I'm using an empty object with a Get Position action that this same variable set to vector, which is placed in the correct spot (has a Do Not Destroy component, same as the Player).  However, when the Player moves through the door and is teleported to scene 2, he doesn't move to the spawn point.  I know for sure I'm missing some steps or using something incorrectly.  Any pointers?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Load level and spawnpoints
« Reply #3 on: September 15, 2021, 08:36:23 AM »
Hi.
Its hard to tell without seeing your setup.

in our game on each scene i have a 'scene manager' and it has an array with spawn locations.

It will get the index from the scene handler (which was set when started loading)

then it will get the position from it and then set the player to that position. (all in world space)