transferring a player between scenes
Hi all I was wondering if there is a way to transfer a player between scenes.
currently I use scene manager and 2 fps players one in one scene and one in the other so that it is at a specific point. Player goes up to gate then is transferred to the other scene the other side of the gate. trouble is I need the player to start at a specific place not where the fps is placed.
I hope this makes scene.
What i'm after is the player to transfer between two scenes at specific points. whilst keeping the starting point.
any tutorials would be welcome as I am not very good with coding. thanks
Answer by angelromp06 · May 06, 2020 at 08:45 AM
@JAS1312 I hope this helps you. I did what you said in a game I made. I made something of a platformer and in the end of the level I made an invisible object
Then I created a this C# script: using UnityEngine; using UnityEngine.SceneManagement;
public class LevelEndTrigger : MonoBehaviour {
void OnTriggerEnter ()
{
public void NextLevel ()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
}
With void NextLevel () now you go to the next scene in level index. For this to work you go to files>build settings and you drag your scene he way you want to go For example here I want level 01 to be the first scene and level 02 the second scene. I drag scene "level 01" to the build settings and scene "level 02" to the build settings just one number after level 01. Otherwise, it won't work. Here after completed level 1 I will go to level 02 because it is the next scene in my build settings. As to move your player to one scene to another, I think you'll have to duplicate your player to exist in both scenes. Please answer to me soon if that works and if you want an animation between these scenes.
Answer by JAS1312 · May 06, 2020 at 09:59 AM
Thanks. I did a different method. i managed to get the player to transfer to the next level and had to duplicate the fps player as you said I may have to. it works great but not quite what i'm looking for. i'll try and make it a little clearer. the idea is the player will start in a house, when the player approaches the gate they will go to the beach and can come back too. I was hoping to be able to do this with out having multiple Fps in the scene as if I do the player will start at one of those points and not in the house. just wondering if there is away i could do this.
thanks though :-)
Your answer
![](https://koobas.hobune.stream/wayback/20220612233324im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Destroyed object in DontDestroyOnLoad does not recreate in its main scene 0 Answers
Teleporting player on key press 1 Answer
Changing character position when changing scenes. 2 Answers
Is there a way to make an Object pass over a Text? 0 Answers
Scene tearing after making camera child of player character. 0 Answers