Hi Brian, thanks for the reply. So basically I had the issue that the part where we set the players transform position to the spawn point position just didn’t work in combination with the yield return SceneManager.LoadSceneAsync(sceneToLoad).
So this method here had no influence at all on the players position:
private void UpdatePlayer(Portal otherPortal)
{
var player = GameObject.FindWithTag("Player");
player.transform.position = otherPortal.spawnPoint.position;
player.transform.rotation = otherPortal.spawnPoint.rotation;
}
The player was always spawned where the gameobject is initially placed in the scene. As soon as I changed the code to the approach with the while loop from the unity docs, the player was positioned correctly to the according spawn point of the portal. So I’m not quite sure why it didn’t do the job with yield return SceneManager.LoadSceneAsync but it appeared to me that it just didn’t wait until the scene was completely loaded. I have to say that my scene is way more loaded with meshes / objects, so maybe this will just come up as an issue if your scene has heavier loading times. Definitely something that would require more testing with different scenes and loading times, in order to identify the problem. From my understanding yield return SceneManager.LoadSceneAsync will return the AsyncOperation to the Coroutine, I’m not sure if it will actually wait until that AsyncOperation is done or what the implemented behavior of unity is on that side. I couldn’t find anything in the docs either.
EDIT:
Also there was no error message, so it just didn’t change the position of the player. I haven’t change anything in the UpdatePlayer method, just the part with the yield return LoadSceneAsync