playMaker

Author Topic: Spawn point player  (Read 918 times)

Andrew_C

  • Playmaker Newbie
  • *
  • Posts: 6
Spawn point player
« on: March 18, 2022, 01:00:26 AM »
Hi all, could someone give me a detailed guide better if a video how to spawn the player in a certain position on scene change?, Unfortunately I did not find detailed guides on how to do it, thank you very much!


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Spawn point player
« Reply #1 on: March 18, 2022, 01:43:39 PM »
Hi,
it depends a bit on your setup.

Is your player not destroyed when changing scenes?
is player spawing on the same position every time he goes to a scene or can it be on different places?

Andrew_C

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Spawn point player
« Reply #2 on: March 18, 2022, 02:09:59 PM »
hi!, in the first scene I have the prefab of the player, I would like that when he goes to the door he goes to the next scene possibly without putting the player prefab also in the second scene, like having an empy object called spawning player and use it both to enter and to exit from the levels, or spawn the player prefab when the first scene starts without putting the prefab inside, I hope I have explained well, thank you very much!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Spawn point player
« Reply #3 on: March 20, 2022, 10:24:51 AM »
Hi.
You can set your player with a 'Don't Destroy On Load' which will make sure your player stays while changing scenes.
You might also want to use Singleton (Ecosystem) to make sure there will only be 1 player
or
You can make a 'Player' Scene and load level scenes Async. (additive)

Set your player in a Global variable.

Then in the level scene you can use a "get Position" and get the spawn point position (or you can set a value directly to the variable)
and then use Set position on the player.

if you have more than 1 spawn point, then you can use an array and set a index variable (on player) which can be used to determine where the player should start.

Andrew_C

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Spawn point player
« Reply #4 on: March 21, 2022, 01:44:54 AM »
Hi! I managed to do it this way ... but I don't think it's correct
I created a trigger and in the fsm I created a global variable (game object) called (player) I put load level and dont destroy on load, in the second scene I created an empty game object and I set on the fsm create game object assigning the global variable (player), the player spawns correctly and keeps the don't destroy on load, but I honestly don't know if it's the correct method, please can't I get a step by step guide to do this? thank you very much

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Spawn point player
« Reply #5 on: March 21, 2022, 09:53:05 AM »
Hi.
For player have a global, then use Get Owner and set your player in the global variable.
The don't destroy should be on the player object.
After that, you don't have to do this again.

In the 2nd scene, use Set Position with the global variable (player) as object.