Need some help with Set Actor Transform

This is going to sound a bit complicated, but hear me out.

I have a working new game/save/load setup where clicking new game from the main menu brings you to character select and then to the first level after character is chosen, and spawns the chosen actor from the character select at the default location I selected. (this part works fine)

I have it in a Sequence where, after all this is done, I check if the level was loaded from a Load Game (this part also works 100% fine!), and if true, I get the player character and call Set Actor Transform inputting the transform from my saved transform data. The saved transform data is working 100%, as seen in the attached image below.

Problem I’m running into (I’m doing this at 4am and most likely am just being stupid) is that it’s not moving the player character to that new transform location as I expect it to. I’ve followed some tutorials about saving and loading the player’s location, and as far as I can see this is how it is meant to be done (specifically regarding the Get Player Character → Set Actor Transform setup). Only thing I’m doing differently is I’m putting the code for the actual transform in the level to-be-loaded’s blueprint instead of in the widget’s blueprint where the load is initiated (from either the main menu load game button or the pause menu load game button), because to do otherwise would overwrite the transformed location of the load with the default location set up in the level blueprint.

I suspect I’m just using the wrong node for this somehow, or using it incorrectly, but I’ve spent too many hours trying various things and not getting any different results (initially I wasn’t doing it in sequence, I simply had the section after my level loaded true/false branch right after the possess node, but I’m now using a sequence to tidy things up a bit).

Any advice for how to do this would be great.

TLDR: I’m trying to spawn the chosen actor at one location, and if the level was loaded from a Load Game instead of New Game, I want to then change that actor’s location to the stored location from the saved game. The only thing not working is it doesn’t seem to care about the Set Actor Transform node.

Edit: also, I realize my Load Character is not linked up to the Class intput, in order to quickly and easily debug this issue I’m having, I needed to see the level blueprint after loading the game, but as I load from the main menu (and using a different level for that to keep things tidy), it’s impossible to see any level blueprint than the one you launched the game from (at least from what I can tell, you can’t open more than one level blueprint at a time). The character loading works 100%.

Can we see the rest of the code ( on the left )?

What you say seems reasonable, but the problem could well be elsewhere…

Sure thing! let me know if you want to see anything else.

Can you show where you set the ‘load level’ bool, and it being saved?

Sure. Basically it’s state is stored in SaveSlot1, and is set to False only in CharacterSelect (it starts as false by default though). It is set to True in each of my load sections (which are all basically identical, there’s just 1 in pause menu and 2 in main menu, since I’m eventually going to have a save game screen for multiple saves and currently have a continue game button for loading the last save. for purposes of these tests I’m showing images from the pause menu since it’s faster to load from there, but the results have been the same from loading from main menu as well).

Here’s some screenshots:



In the second last image you can see how the saved transform is stored. saved character and saved level all seem to work 100% fine, and saved transform is shown in the level blueprint as having the correct data, too. It just isn’t using that data. Very likely something dumb I’ve not considered is happening. Most issues I run into fall into this category of “dumb things I didn’t consider.”

What are you doing with this spawned character?

Ah

Once you call open_level, everything after that gets binned. Try changing the order, and put the open level all on the end.

That is piped into Possess node with Get Player Controller.

I don’t think that’s the case. If that was the case, everything after it would be binned, and thus I could not load my character or the level (and yet I can). Also, Level loaded wouldn’t be set to true there either.

But, just in case, I moved the open level node to the end before remove from parent, like you suggested. Tested it, and it made no difference.

Basically, I am able to load the saved character and it spawns that character when level’s Begin Play runs all the way through. I am also able to load the level map that way, too (as that’d be the only way to load the level map from the main menu, since main menu otherwise can only go to character select). The saved transform data is visible and obtainable by the level blueprint. It’s just not making use of it.

Come to think of it, I’m making a 2d sidescroller beat em up game…

Even though I want players to be able to save their progress, historically I can’t think of any beat em up game that allowed you to specifically save and load the in-level/map location. It would only let you save the level itself so you can try again from the start of that level later on. So really, it’s not a big deal that this isn’t working for this game I’m making. That said, I’d still like to know WHY this isn’t working, because future games I make may make use of specific location saving.

As far as I can see, I’m doing exactly the same thing as Matt Aspland does in this video:
How To Save And Load Player’s Location - Unreal Engine 4 Tutorial

Although now that I think about it, his video says Unreal Engine 4. He APPEARS to be using Unreal Engine 5 (it looks like it anyway), and that’s what I’m using, but you can never really be sure. It might be an engine issue.

And if you put a print there, does it print ( on the set transform )?

So get this, it seems the trouble is that it’s not getting the correct value of Level Loaded from the game save, and so my branch is not going through. Even though the value is definitely being stored correctly from the load game code (as seen in the image below, I added a print string to print the value to the screen).


But then with further testing on the level blueprint, it’s seen that the branch is hit but then doesn’t follow through because it’s triggering the False output, and Load Level value says false.

I’m thinking maybe it can’t be stored in the save game class. I’m going to try putting it in my game instance class instead, see if that works better.

You can store a bool in the SG, of course :wink:

Yep that seemed to be the problem. Not sure why, but apparently you can store data in a save game class, but can’t load from it, for loading you have to use the game instance class. I was already using the game instance class for loading most information (the level, the character, and the location data), but even the tiniest of booleans can’t be kept unless they’re stored and loaded the same way.

But but but… :slight_smile:

You can save and load using the SG, that’s the point of it :rofl:

Using the GI will work fine until you try to restart the game.

See that’s what I thought the game instance class was for, too. But that’s the only thing that fixed it for me. APPARENTLY when I load any level, the save game class I have is reverting the bool back to default (false).

I replaced the cast to saveslot1 set/get load level part of my code with a get game instance>cast to mygameinstance with set/get a similar bool, and that seemd to have worked.

Either I don’t really get the different uses between SG and GI, or something weird is going on.

Basically, from my understanding of it, the SG is for keeping the information even if you close the game (obviously), but won’t let me load that same information directly, I have to pipe that information through the GI. I was already doing that for the player character class and the level and the transform, BUT I wasn’t doing that for the bool.

I figured updating the bool in the save between true and false would be enough, making it true when I load, and false when I go new game. But while clicking Load made the bool true, once the level loaded the bool was back to false again (the default state of the bool in this case. it was nothing in my code setting it to false since I was not going through the character select at all).

But that seems to be what it was doing. The moment the level was swapped from the previous instance of itself to the new instance of itself, the value of Load Level from the save was back to false. That SOUNDS contradictory to what a SG does.

Basically, it looks like I’m going to have to save and load everything that needs to be saved and loaded the same exact way. Save to the SG, and set the same data in the GI, setting it to match the SG, the same way I currently already did for the player character, transform, and level.

here’s a quick video showing it working now:
testing of saving and loading

It’s nuts :slight_smile: You don’t need both.

You have a code error, it’s nothing to do with the SG.

Here’s my SG 101

Well, I got it working, but I’m not exactly happy about it. XD

It’s clear I have some sort of error somewhere preventing me from just loading the information from the SG in the level blueprint. And I’m the sort of programmer that would rather make things as efficient as possible and make things work the way you expect it to work rather than work some other way by coincidence.

So even though, yeh, I got it working, I’d rather it work the way you and I expect it to work, which is allowing me to save things to the SG and load directly from the SG (like you have in your image above), leaving the GI out of it.