keywords: [UE4]Movement and Networking Related

keywords:UE4、Movement Replicate、Networking、Server、Client、Smooth

引擎对于客户端服务端的位移同步,CharacterMovementComponent::SmoothCorrection()函数中有进行平滑处理。

Reference

其他参考资料:
What is the best way to smooth player movement for network hiccups? Interp? Ease? (no physics)
https://answers.unrealengine.com/questions/479211/what-is-the-best-way-to-smooth-player-movement-for.html

Authoritative Networked Character Movement
https://wiki.unrealengine.com/Authoritative_Networked_Character_Movement

Advanced Topic: Adding New Movement Abilities to Character Movement
https://docs.unrealengine.com/latest/INT/Gameplay/Networking/CharacterMovementComponent/index.html#advancedtopic:addingnewmovementabilitiestocharactermovement

Custom Character Movement Component
https://wiki.unrealengine.com/Custom_Character_Movement_Component

Dedicated Server 的 Movement 优化

如果仅仅为了性能,不希望服务端实时修正客户端坐标,以客户端发过来的坐标为准,可以开启以下选项:

[/Script/Engine.GameNetworkManager]
 MAXPOSITIONERRORSQUARED=625
 ClientAuthorativePosition=true

但是这么做会被外挂 hack

参考自:How am I able to Replicate movement when using “AddMovement Input”, but not AddLocalTransform?
https://answers.unrealengine.com/questions/26116/able-to-replicate-movement-when-using-addmovement.html

Console Commands
int32 NetShowCorrections = 0;
FAutoConsoleVariableRef CVarNetShowCorrections(
    TEXT("p.NetShowCorrections"),
    NetShowCorrections,
    TEXT("Whether to draw client position corrections (red is incorrect, green is corrected).\n")
    TEXT("0: Disable, 1: Enable"),
    ECVF_Cheat);

float NetCorrectionLifetime = 4.f;
FAutoConsoleVariableRef CVarNetCorrectionLifetime(
    TEXT("p.NetCorrectionLifetime"),
    NetCorrectionLifetime,
    TEXT("How long a visualized network correction persists.\n")
    TEXT("Time in seconds each visualized network correction persists."),
    ECVF_Cheat);

人们常常用咄咄逼人来掩饰弱点,真正持久的力量存在于忍受中,只有软骨头才急躁粗暴,他们因此丧失了人的尊严。我等待,我观看。恩惠也许来,也许不来。也许这种既平静又不平静的等待就是恩惠的使者,抑或恩惠本身。──弗兰茨·卡夫卡(Franz Kafka)