Hi, I am a beginner to UE4 (I’ve only been using it for 4 months now, and I have no prior game engine knowledge), and I’ve run across a problem that I’ve failed to find a solution for in any of the forums/Q&As. I have been making a game, and I have a LOT of saving that happens. Last night, I renamed my project, I looked up how, and I changed the gamename URL thingy, and I changed the project name. When I enter the pop-up that asks which project I want to open, the name is accurate. But after I renamed the game, it seemed as though my save game wasn’t working. So I deleted the old one, and replaced all my references with a new one. I have accurately replaced all the variables and stuff, and the “load game from slot” code seems to work, but whenever my code gets to a “Cast to save game” node, the cast fails. I spent about an hour or two, going back to my files, and mass renaming my computer files so that anything I could change would be accurate name-wise. I deleted the old save .uassets and (.upex?) files, and as I mentioned above, the game is saving, it’s just failing when I cast. Here are some pics of my code:
As you can see, I’ve added print strings to tell me whether the cast node is activated, and whether the cast fails or succeeds. Every time the code is run, the print strings say “yup1” and then “nope”, meaning the cast fails. I don’t know why though? I’m confirming that the load game from slot exists, it does exist, then the cast fails. I really need to get this bug fixed, since without save game data, my game is ruined. As a last resort, I guess I could replicate the game onto another project, where the renaming never happened, and the save game object doesn’t have any complications, but I would like to know how to fix this, in case it ever happens again.
I don’t know the correct answer, but things that seem wrong to me are:
Casting after Create Save Game Object: you already create an object of the type you need. Casting here is unnecessary;
You’re saving the Game Save Object to a variable after loading, not after Casting. IDK if they conflict with each other in any way, but to me it seems that when you Create Save Game Object, you save your SpyRun_Save type into a variable, but when you load game, you save a generic Save Game Object into the same variable.
For the debugging purposes, try making the same without the variable – just connect everything you need to your Create Save Game Object and Cast to SpyRun_Save nodes.
Okay, I’m new to saves and stuff so maybe I didn’t completely understand you, but I think I did what you said:
It declutters the code a lot, which is very helpful 0u0 ! Unfortunately, the cast is still failing 0n0.
Also, all the code was working before, but I think something is wrong with my save game object files. The only difference between this code and my last code is that I use a different save game object, which I guess the reason I deleted the old one was because it wasn’t working, but that was only after I renamed the project.
Okay, another thing that comes to mind: the HighScoreData slot contains a save that isn’t “SpyRun_Save”. If it’s so, your code will never create a new object to overwrite the existing one, and Cast will always fail.
My solution would be not to use the [Does Save Game Exist] node, and use Cast instead:
First of all, face palms himself yes, the HighScoreData slot was originally under the previous save game, so that was probably one of my problems.
Here is my new code:
However, it still doesn’t work, and every time I run the code, the “nope” string appears.
So now all I need to do is reassign the slot names to the rest of the objects that require saves. It would appear that the way this happened, was that when I renamed the project, it glitched the save game, and then when I created a different save game object, it made the slots incompatible with that save. Thank you, Tuerer, I’ll start reassigning and decluttering my code right away! 0u0
When I renamed the project, the save files that went with it glitched. That’s why the old save game wasn’t working. When I created the new save game object, the game slots associated with the old save were unable to save to the new save. By reassigning my game slots, they start to work again, albeit at the loss of my previous data.
You totally just “saved” me a ton of troubleshooting royal force.
So just for a bit more clarity on the issue for anyone else with this problem. If you create a save game blueprint, then at any point after decide to rename your project, the old save game blueprint you created will no longer work. I’m assuming it keeps the directory of the previous project name, and the cast will fail because its no longer using the same file location. So my fix was to make new save game blueprints, and we’re back in business. Thanks again royal force
Just a side note for those still experiencing trouble, after deleting the save game file, whether that be by directly deleting it, or deleting the save folder or save-game folder, make sure your code detects this by adding in a “does save game exist” node (or the corresponding c++ function I guess), and if the boolean returns false, then run some more code that creates a new save game. If you’re still experiencing trouble, you can message me and I’ll try my best to help out (Just don’t be surprised if it takes awhile for me to respond, my email is terrible at notifying me).
HAHAHAHAHAHAHAHAHHAHAHAHAHAAHHHAAHAHAHAHHAHAHAHHAHAAAHAHAHA, oooh, this is funny, yeah, i had the same problem, HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHAAHHAHAHAA, aaah. very funny.