Issues with Player Location


Author: Zoleda Davila

Posted on 2/23/24



This week, one of my tasks was to fix a bug with the player location that was discovered in the previous milestone's build. The issue was that when you played the game and exited to the main menu then loaded the game again, the player would spawn in the town map in a random location that made no sense to the gameplay. As I kept testing to try and implement this bug again, I also noticed that when you spawn into other maps that are not a part of the actual game (i.e. team member testing maps), the player would spawn away from the ground and would continously fall until you exited the gameplay. This caused users of the game to no longer be able to continue the gameplay and hinder the experience.

In order to fix this I looked at the Game Instance blueprint I made to personally customize the save system as well as the BP_Level Transfer Base blueprint. The BP_LevelTransfe_base is the colliding object we use to travel from map to map in the game. 


I noticed that when debugging, the player transform is always getting saved wen they load into a new map; however, the way the game was set up to start when we didn't have a way to load a saved game option was that you would start the game in the town map. So, the player would spawn in the town map at the last saved location the player was at before quitting the game. If that map was anywhere other than the town map, the spawn point would be funky. 


To fix this, I added another variable to the Game Instance that would also save the map that the player was last on during gameplay. Then, when the player would want to load a previously saved game, the saved level would open up at the beginning of the next gameplay with the correct position for that specfic map. 


If the player wants to start a new game, the saved game object would be deleted and the default values for the saved game object will take over. For the level variable in the saved game object, the default variable would cause the game to start at the town map. After much testing the player can now spawn at the correct position for each map at the beginning of each gameplay.

Leave a comment

Log in with itch.io to leave a comment.