GUID is different between different scenes

Hi for some reason everything is working for me just like Sam’s code except for my Players GUID when I switch between scenes.

If I empty the GUID it creates a new one, but then I end up having to do the same on the other scene so the player on each scene always has a GUID that is different from the player on the other scene, hopefully that made sense.

Is this the same issue described in:

Our players are a special case. We need to manually type in “Player” in the ID field, otherwise it will just assign a random one, which we don’t want. Anything that we need to be the same between scenes (usually the player, but maybe a bank branch?) should have it’s ID set manually.

1 Like

I put Player in the UID in the players prefab and that made it the same across all scenes, but I’ve now ran into a bug where the player loads based on the save location from a different scene.

I don’t think the save system takes into account the scene the UID is in so the values will be exactly the same including the transform from scene to scene.

I assume there is some method later in the saving section for transferring all of the players stats,xp,hp etc even though there is a different UID for each player from scene to scene?

No, because the Portal should be restoring the player based on the “Player” ID, then finding the new player in the scene and moving the player to the correct location for the portal. If the ID is different, those stats won’t transfer (because it only restores the states of SaveableEntities that are physically in the scene and leaves ones that aren’t in the scene untouched).

  • Save (CaptureState) the scene, entry for Player is overwritten and location in save file is from the old scene
  • Load new scene
  • Load (RestoreState) all of the data in the scene. The player’s hp, exp, etc is restored, including the location from the previous scene
  • Move the player to the new Portal’s spawn point
  • Save (CaptureState) the scene, entry for Player is identical to the one from the previous save except for the Mover’s coordinates which should now be the spawn point.

I’ve found the issue is unless I’ve missed something is that if you come out of play mode and go to a different scene to which you last saved the transform bug happens then.

Which I guess wouldn’t be an issue in actually playing the game unless someone wanted to expand upon the saving system and add the option for multiple save file which also load different scenes.

I’ve later found this bug is addressed in the lecture:

That still shouldn’t happen, since when you start a game from a different scene, LoadLastScene() loads the last scene the character was saved in, which should have the character in the correct position.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms