I am trying to teleport my client player to a location in blueprints, the server can teleport just fine, but the client is teleported, remains at the location for 1 frame, and is reverted back to their old location. The same applies to ‘Set Actor Location’. I am using ‘Get Player Character’ at index 0 as my target. I am calling this code from a menu UMG widget. Can anyone help me out?
Since this is Multiplayer, the Client is simply not allowed to perform such an action on its own. Otherwise every client could cheat his position to whatever place he wants.
You need to use a “RunOnServer” event (in the PlayerController for example), that you call from your UMG Widget and let the Teleport or SetActorLocation be called on the Server.
The “1 Frame and reset” thing happens, because you are trying to set the Players Position from Client and the Server (and all other clients) still have the old position and in the next
frame, the Server corrects the attempt to change the position with the correct position that he has (Server is the authority. No one is allowed to change something, that is marked
as replicated, on its own!).