How do I save a Player's Direction?

Hello,

I wanted to implement an autosave feature, so I followed this tutorial:

The problem appears to be that while the position of the player is saved, their direction isn’t. So if someone dies facing east, they spawn facing east, regardless of their direction when first passing the autosave trigger.

I attempted to get and set the player’s camera rotation, but that doesn’t appear to be doing anything and at this point my logic is getting a bit messy. Am I doing something wrong here?

It also seems like a great deal of work if I have to set and reset every single thing I want to “reload”, is there somekind of ‘world state’ I could load/reload instead? I don’t see how this solution would scale if I had to save/load things like enemies and physics objects and the like.

Any assistance would be greatly appreciated.

1 Like

Try using ‘get control rotation’ and ‘set control rotation’ ( from the player controller ).

1 Like

When you spawn the characters you can adjust rotation. If you need them to respawn in the same rotation after being destroyed then like Clockwork said use get control rotation and promote its output to variable and set it right before the destroy actor and give that data to the respawn.

1 Like

In your Controller class create an event “Set Client Control Rotation”.
Details panel set Replicates: Run on Owning Client.

In the Game Mode class after you spawn the character call the event.

2 Likes

I ended up going with a different solution:

But I still appreciate the insight! Many thanks.

just as an insight, any movement related action has to be called on the local client first if using any of the pre-built movement components.

Could you break this down into laymans terms for me? I am very new to this and I’m not sure what any of this means.

Lets take the first and third person template characters for example. These characters use the Character movement component (CMC) to move the character. CMC utilizes client-side prediction to add responsiveness to the owning clients inputs. Client-side prediction in simplest terms is execution of movement input on the owning clients simulation, then on the server.

When you apply movement input (WASD) these inputs execute movement logic immediately locallyOn the owning simulation.

The command and result are stored in a SaveMove struct which is buffered. At the next ClientNetSendMoveDeltaTime the buffer is flushed and all those saved moves are sent to the server.

The server applies the moves to its simulation and sends the results to all other clients. It then compares those results against the results you sent. If they are close enough, the servers sends you an ACK to validate the move. Otherwise it sends you a correction… its results for the move. Velocity, location, rotation etc.


The server can apply corrections through CMC to all character states. Velocity, location, rotation custom vars etc. It can also Teleport the pawn at will (location), but the majority of rotation to pawn/camera, outside of a CMC correction, will be overridden by the clients current rotation.

For example if the server applies a rotation to the pawn not initiated through CMC it will only apply to the server. The client will not see the result. Owning clients only see corrections for the most part.

You can easily test this by having the server apply Set Control Rotation and/or set the capsule component rotation via timer.

Neither rotations will be applied to the client.

1 Like

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