Hi everyone,
I’m facing a strange issue related to character spawning in a packaged build of my game.
Originally, I had a save/load system where the character was being spawned based on saved data. However, after packaging the game, I noticed that the character would always spawn at its previous location regardless of the intended behavior.
To fix this, I implemented a custom spawning system inside the GameMode
, where I manually spawn the character at the desired location and call Possess()
on the PlayerController
. Everything works perfectly in the editor — the character spawns at the correct location and gets possessed properly.
But in the packaged build, the character always spawns at world position (0,0,0) and does not behave as expected. I’ve already set:
DefaultPawnClass
to None
in the GameMode
- Disabled
Auto Possess Player
in the character blueprint
- Ensured that
Possess()
is only called after the player controller is fully initialized (even added a delay for testing)
Despite all this, the issue persists only in the packaged build.
Has anyone encountered something similar, or is there a known workaround for this? Any help would be greatly appreciated.
Thanks in advance!
How do you retrieve the desired location ?
Based on your explanation I wonder - are you trying to read it from a Savegame ?
Other than that, you probably shouldn’t be cancelling and replacing the spawning pipeline for this - Override the right methods to make it behave as desired.
-
When player connects, FindPlayerStart is called and the result, which should be a random PlayerStart actor, is stored in Player->StartSpot.
-
When player needs to spawn, FindPlayerStart is called again, but this time it will return Player->StartSpot if not null.
In your case, I suggest creating a lightweight actor that will serve as dynamic start spot.
In GameMode initialization, spawn it and and store it as a variable. Override FindPlayerStart and simply return that actor.
Then, whenever you need to update the start spot, simply move that actor where you want, and the player will respawn there next.
If the start position needs to be retrieved asynchronously, you can also override function PlayerCanRestart, and return false until the data is ready.
1 Like
this is my current setup for getting the desired location.
It is a bit odd that you are getting the SaveGame first, and then checking DoesSaveGameExist.
Can you tell which path is running when in doesn’t work (in shipping) ?
It might just be a case of the SaveGame not being available in shipping build - the savegame from the editor will not be packaged with the game, you need to generate a savegame from the shipping build itself.
You need to somehow rule out the cause of the issue - it may either be that the SaveGame is not available/detected in shipping build - or the SaveGame doesn’t contain the correct position - or the spawning system simply doesn’t work. Considering your stuff works in editor I’m leaning toward the former. To confirm that, instead of reading from SaveGame, try hardcoding a location to spawn the player at. If that works, then your spawning system works and the problem is the SaveGame.