Announcement

Collapse
No announcement yet.

Need help for fixing net correction while interpolating of actor location in multiplayer games

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need help for fixing net correction while interpolating of actor location in multiplayer games

    Hi there,
    I'm trying to interp my character location over a short amount of time in my multiplayer game. so I created my CharacterMovementComponent and override the needed classes but there is still NetCorrections when I use SetActorLocation. So if anyone know about this problem and how to fix it please let me know.

    Code:
    void UBaseCharacterMovementComponent::OnMovementUpdated(float DeltaTime, const FVector& OldLocation, const FVector& OldVelocity)
    {
        Super::OnMovementUpdated(DeltaTime, OldLocation, OldVelocity);
    
        if (bWantsToInterpLocation)
        {
            float goalTrackPos = (TrackID == 0 ? TrackDepth : -TrackDepth);
            float newX = FMath::FInterpTo(CharacterOwner->GetActorLocation().X, goalTrackPos, GetWorld()->GetDeltaSeconds(), 5.f);
            CharacterOwner->SetActorLocation(FVector(newX, CharacterOwner->GetActorLocation().Y, CharacterOwner->GetActorLocation().Z));
    
            if (FMath::IsNearlyEqual(CharacterOwner->GetActorLocation().X, goalTrackPos, 1.f))
            {
                TrackID = (TrackID == 0 ? 2 : 0);
                bWantsToSwapTrack = false;
            }
        }
    
        return;
    }
    I also interp MaxWalkSpeed in my CharcaterMovementComponent too but it works correct. So I don't know what is different here with SetActorLocation.

    Click image for larger version

Name:	image4302020234816.jpg
Views:	94
Size:	142.5 KB
ID:	1753357
Working...
X