Movement Replication - Need explanation

Hi,

I’m trying to setup a “Freeze” in a multiplayer game.

While I can clearly disable the input on the ClientSide, I don’t want to only do that as I can’t trust the client so I need to also make sure that the server “freeze” this character.

I need to stop all movement (velocity = 0) and all look changes.

What’s the best way to do it?

As of today, I’m lost in all the different function of the CharacterMovement class.

I did try to put Velocity to FVEctor::Zero in ServerMove_Implementation but it will just lock the character on the Server (listen client) but the other clients still use some prediction data to move it…

Thanks for your help!

Bonus: I need to be able to teleport the character on Server Side while it is frozen

To “Freeze” player you can call on server side:



APlayerController::DisableInput(class APlayerController* PlayerController)




APawn::TurnOff()


this disable input from player and stop all movement/animations of pawn, and server automatically replicate pawn state to all clients.

To teleport player just apply new position(AActor::SetActorLocation should work) to pawn on server side.

Thanks, I didn’t knew about the TurnOff function. That should do what I want.
To “turnon”, is it restart that should be call?

Are you sure about DisableInput on serverside? isn’t it a Client function not use serverside? Because, the servermove function will receive data for client (after using the DisableInput flag), I’m not sure it’s tested back again while receiving data on the server.

TurnOn you should write by yourself, just look what disables in TurnOff function and enable it back.

You right - DisableInput should be executed on client. You need to create client RPC(which will call DisableInput/EnableInput) and call it from server.

If its important you can implement it as an “ability” incorporated into CharacterMovementComponent, doing so do require quite some work however and might be an overkill depending on your needs.

https://docs.unrealengine.com/latest/INT/Gameplay/Networking/CharacterMovementComponent/index.html

This article explains quite well how its done and drawbacks of various other methods

Thanks for the feedback. I will do more test tonight on this.

@Lyan,
I won’t use it as an ability as it’s a server side decision to freeze a character and not from the “User client side”.

My issue as of today was the client side replication. Owner & Server was handled properly but on a 2nd client, the 1st client was still moving (prediction) and I wasn’t sure on how to fix this properly.