Download

Smoothing (interpolating) bReplicateMovement?

I’ve been trying to understand how CMC interpolates server location and client location for two days. I am willing to replace CMC with UFloatingPawnMovement, but since it is not replicated, only thing I can do is enabling bReplicateMovement and interpolate client’s position to server position. I understand the theory and how it is working, but I dont understand how I should setup the system/code.

https://answers.unrealengine.com/questions/479211/what-is-the-best-way-to-smooth-player-movement-for.html

In here, Zak explains two ways to do this, first one is using RPCs on Tick and interpolating yourself. And other (also most performant one) is using CMC way. I tried to implement CMC way, but since CMC is already too complex for someone just started networking, I am unable to solve the interpolation code by myself.

This is what I’ve done:

There are at least 10+ threads/questions related to this topic on both forums and answers.unrealengine.com but none of them giving a clear solution. Most of them is about physics replication, there are some few threads about non-physics movement replication, and most useful one is the one I’ve dropped above. I dont understand where “MeshTranslationOffset” should come from, or why we are doing this:

FVector NewRelTranslation = GetComponentToWorld().InverseTransformDirection(MeshTranslationOffset) + DefaultMeshOffset; (this method is old and seems like deprecated btw)

And seems like bReplicateMovement already teleports both root and child components together, I dont understand how should lerping or changing relative location work.

Video link: https://jmp.sh/pXu9FAA (jumpshare link, alternative to gyazo, its safe.)

In that video, I have the code I’ve provided with pastebin. I know I am missing a lot of things, if someone can guide me, I would be glad.

For the last attemp, I’ve tried this. I exactly copied this from UProjectileMovementComponent. And it also matches with Zak’s method. I am running this on Tick(). But, instead of relative locations, all of the pawns are went to “world” location of 0,0,0 :
help.jpg

Also there was a



void UProjectileMovementComponent::MoveInterpolationTarget(const FVector& NewLocation, const FRotator& NewRotation)

in ProjectileMovementComp. but I tried to breakpoint it, and there wasnt any usages. Seems like this function is responsible for setting LocationOffset for interpolation. In docs, it says this functions being called on net updates. But it isnt. Also, this function is populating some variables used in interpolate function in projectilemovementcomp. I’m totally lost. Since PostNetReceiveLocationAndRotation cant be overriden in components, I cant use the context of that function too. So how can I smooth the movement in pawn movement? It cant be “that” hard.

There’s an official multiplayer tutorial available for free here: https://learn.unrealengine.com/course/3750188