#Question on UCharacterMovementComponent->ApplyRootMotionSource and replication
1 messages · Page 1 of 1 (latest)
if (UCharacterMovementComponent* MovementComponent = Cast<UCharacterMovementComponent>(GetMovementComponent()); MovementComponent !=
nullptr)
{
MovementComponent->RemoveRootMotionSourceByID(RootMotionSourceID);
TSharedRef<FRootMotionSource_MoveToForce> RootMotionSource = MakeShared<FRootMotionSource_MoveToForce>();
RootMotionSource->InstanceName = FName("RootMotionMoveToForce");
RootMotionSource->AccumulateMode = ERootMotionAccumulateMode::Override;
RootMotionSource->Settings.SetFlag(ERootMotionSourceSettingsFlags::UseSensitiveLiftoffCheck);
RootMotionSource->Priority = 1000;
RootMotionSource->StartLocation = MoveStartLocation;
RootMotionSource->TargetLocation = MoveEndLocation;
RootMotionSource->Duration = 1;
RootMotionSource->bRestrictSpeedToExpected = false;
RootMotionSource->FinishVelocityParams.Mode = ERootMotionFinishVelocityMode::SetVelocity;
RootMotionSource->FinishVelocityParams.SetVelocity = FVector::ZeroVector;
RootMotionSourceID = MovementComponent->ApplyRootMotionSource(RootMotionSource);
UE_LOG(LogTemp, Display, TEXT("Do move local role %s, is locally owned? %hhd"), *UEnum::GetValueAsString(GetLocalRole()), IsLocallyControlled())
}
Here's where I'm applying the root motion source, possibly there's some config I'm missing, or some function I'm not calling?
Question on UCharacterMovementComponent->ApplyRootMotionSource and replication
Here's what it looks like, in the video I move in and out of cover (press and release space bar) twice on the server, and then twice on the client.
In this version, I send a server RPC from the client to apply the same root motion source, but you can see that there's a lot of corrections being made, resulting in the jitter.
LogNetPlayerMovement: Warning: *** Client: Error for BP_TimeShooterCharacter_C_0 at Time=21.117 is 0.000 LocDiff(X=0.000 Y=0.000 Z=0.000) ClientLoc(X=450.000 Y=50.040 Z=298.400) ServerLoc(X=450.000 Y=50.040 Z=298.400) NewBase: Lvl_Test:PersistentLevel.StaticMeshActor_34.StaticMeshComponent0 NewBone: None ClientVel(X=0.000 Y=0.000 Z=0.000) ServerVel(X=0.000 Y=0.000 Z=0.000) SavedMoves 12