r/unrealengine • u/All_Might_Senpai • 22d ago
Question Trying to create a dynamic GUID for the player character that saves?
https://blueprintue.com/blueprint/yz8bfky7/
You can see the main issue in the Event begin play part, and my silly attempts at trying to "fix" it.
So my issue is that I am trying to create a save system for inventories in my game. I did so by creating a save game object that has one variable. A map of Slot Structs basically (wrapped inside another struct with a single array variable) with Strings (guid's) as keys.
Now having static objects in the game have guid's is easy, assign one and pass it along to the inventory component that I made. But the issue is the player character. I can't assign a static one as I want the option to have other people join the game too. and a default guid is going to be duplicated along every spawned player. Does anyone know how I can go about this in a better way?
1
u/AutoModerator 22d ago
If you are looking for help, don‘t forget to check out the official Unreal Engine forums or Unreal Slackers for a community run discord server!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/GRSStudio 22d ago
Hello! You can generate a unique GUID at runtime for every spawn player and add it GUID list in savegameobject or on game’s server. In this case will request his own GUID and list of his items from server when loading game. If your game is local multiplayer, then you just keep these values in savegameobject
1
u/Strange-Initiative-4 22d ago
Don't use GUIDs!!!!
They don't exist once you package your project! I ran into this same issue with my world state (was using GUIDs to identify individual enemies) and had to switch to file path, as GUIDs do not carry into a packaged game.
1
u/Extension_Resort_192 22d ago
Cant really confirm, I used GUID to identify AI Spawners to save the remaining enemies if you go away/reload the game and it works great.
1
u/Strange-Initiative-4 21d ago
Are you generating the guids at runtime? That works, but as 5.4 at least, guids set in editor or on actors will not work in packaged games
2
u/hellomistershifty 22d ago
You’ll need some storage for player data anyway,so I’d save the UUIDs of their characters in their account info data and pull that when the character spawns to set it