Setting Actor Transform after loading level gets overwritten immediately after.

the context:
I started with the 3rd person template, I made a bare-bones Save system using blueprints, for now it just saves the last open level and the player’s transform. For loading, this is the load function in question (From the Game Instance) and how the player character is handling it.

the Problem:
The “Load Saveable Data” Function is called properly, and it gets the right data, it teleports the player to the saved transform but get immediately teleported back to the default transform. Checked online videos of people using “Set Actor Transform” and it seemed to work fine for all of them on its own, I went the extra mile and disabled physics simulation just in case, but it changed nothing.

I am really lost here, it is probably something dumb somewhere that I forgot, or I am doing it wrong, but I have no idea what or where it might be. Any help would be welcome. Thanks in advance.

1 Like

This is the problem

Open level trashes everything else that’s going on, except the game instance.

So, maybe the stuff to the right of this node probably isn’t getting run. Even if it is, for a moment, then the open level call takes over and the player gets put in the default position.

2 Likes

That function is running from inside the Game Instance, so in theory, shouldn’t it still execute?

It might be it, in which case which function would I have to overwrite to make sure it doesn’t?

1 Like

If you want to use open level, then you have to reposition the player after the level has opened. Assuming the level is not also spawning a player from the game mode.

You can do that from the player or GI, but not until ‘open level’ has finished. There is no ‘call back’ to let you know when that’s happened.

One way to know, is to put a well known actor in the level, with an actor tag. When you can see the actor, it’s ok to move the player.

2 Likes

Thank you!
I am quite certain the game instance is changing the transform of the player though because I can see them in the loaded transform for a frame or 2 before reverting to the default. So, I know that something is overwriting the transform.

Tried deleting the Player Start and placing the actor directly with auto possess enabled just to narrow it down, the transform is still getting overwritten.

That something is, as @ClockworkOcean said the Open Level node. Open Level node takes some time to load the level then display it, in that time the Game Instance manages to set the transform. But as soon as Open Level finishes loading, It Opens the Level without any modifications you made through code, replacing the previously transformed actor back to it’s unmodified transform.

2 Likes

My apologies, I guess I didn’t quite get it the first time. Currently not at home to test anything but I assume the best fix would simply be a little delay before trying to set the transform?

1 Like

@ClockworkOcean is correct. Teleport after the level is loaded.

2 Likes

Thank you! Now after trying to delay the execution it all made sense about everything you both said over and over. My problem still isn’t solved but my question has been answered, marked as solved. Will try to mess around some more with the newfound knowledge and lets hope I don’t need to make another thread about it.

1 Like

One of the most simple places to put the transform code, is in the level blueprint of the destination level. Just read the save game and set the player there, just to get it working first… :slight_smile:

Tried to use the Level as you suggested, and it definitely works. My new issue is more about how to actually wait for everything to load before moving things around. Tried to spawn an entirely new actor who will handle the loading after a delay since the game instance can’t do delays, but the actor is only there for a single tick before everything reverts back to default.

Now, thanks to you, I know that the level blueprint will probably work since it can delay just fine, but having to add the same logic to every single level seems like an over-complication of a simple issue, so I’ll keep it as a last resort if everything else fails.

1 Like

Like I say, put a player start ( or any known actor ) in the level. When you ask for the level to load, wait until you can see that object, then you can position the player.

You can do the wait like this

This is inside the player, doesn’t have to be, just an example.

( You have to put an actor tag on the player start for this to work, of course … )

1 Like

I do the same process as @ClockworkOcean notes, but with a loading pawn.

Game mode default pawn is a simple loading pawn, no mesh. It’s job is to determine if the world has loaded enough to spawn the actual character. During load (large level) the controller uses a “loading screen”. When the pawn reports to the controller that it’s good to spawn I fire RPC’s up the chain to the GM and have it spawn/possess the proper pawn at a specified spawn area.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.