I want to use "SimpleMoveToLocation" on Network

I’m making a kind of multiplayer game that my character moves to a point where I clicked. And it would be run on dedicated server.

So I set the NavigationMesh on the level, and checked “Project Settings->Navigation Systems->Allow Client Side Navigation”. And wrote movement code like this:

-MyPlayerController.cpp

void AMyPlayerController::MoveToClickedPoint()
{
    FHitResult OutHit;
    GetHitResultUnderCursorByChannel(ETraceTypeQuery::TraceTypeQuery1, false, OutHit);
    UNavigationSystem::SimpleMoveToLocation(this, OutHit.Location);
}

It works on a single-player mode but doesn’t on a dedicated server. So I tried an alternative way; build a path and make its pawn trace the path points.

-MyCharacter.cpp

void AMyCharacter::SetPath(UNavigationPath* NewNavigationPath)
{
    NavigationPath = NewNavigationPath;
    TargetPointIndex = 1;
}

void AMyCharacter::MoveToNextPoint()
{
    TArray<FVector> PathPoints = NavigationPath->PathPoints;

    // End of path
    if(PathPoints.Num() <= TargetPointIndex)
    {
        NavigationPath = nullptr;
        return;
    }

    FVector Dist = PathPoints[TargetPointIndex] - GetActorLocation();
    Dist.Z = 0.f;
    FVector TargetDirection = Dist.GetSafeNormal(MoveTolerance);

    if(TargetDirection.IsNearlyZero())
    {
        ++TargetPointIndex;
        // Recall itself to next step
        MoveToNextPathPoint();
    }
    else
    {
        AddMovementInput(TargetDirection);
    }
}

void AMyCharacter::Tick(float DeltaSeconds)
{
    Super::Tick(DeltaSeconds);

    if(NavigationPath)
    {
        MoveToNextPathPoint();
    }
}

-MyPlayerController.cpp

void AMyPlayerController::MoveToClickedPoint()
{
    FHitResult OutHit;
    GetHitResultUnderCursorByChannel(ETraceTypeQuery::TraceTypeQuery1, false, OutHit);
    UNavigationPath* NavigationPath = UNavigationSystem::FindPathToLocationSynchronously(GetWorld(), GetPawn()->GetActorLocation(), OutHit.Location);
    Cast<AMyCharacter>(GetPawn())->SetPath(NavigationPath);
}

It works fine on network but I want to use the “SimpleMoveToLocation”. Is there any way to use it? Should I use RPC? Or any other ways?

Hey there, my guess is that the position and rotation of your character is being enforced by the server, so you might move in the cliente, but the server resets it again, so you might need a server rpc to run the SimpleMoveToLocation on the server so the position and rotation is replicated to the client.