I started with Top-Down Code Demo, and adjust the playercontroller.h as well as playercontroller.cpp to replicate the location from client to server.
However, the walk animations don’t play on the Client (he kinda just jitters and slides around). Server side plays the client walk animation, so I need to replicate this somehow. But I thought all movement should be replicated by default.
One more issue is the movement speed is very different from Server to Client. The client walks at a much slower pace, I don’t know the cause of this.
I have a feeling the SimpleMoveToLocation Function isn’t the best thing to use for networking games.
Any advice would be great, I haven’t made much progress on this in a long while. Is there a better solution for this type of movement?
This code is being ran by the server from request of the client to update the client movement/location in the playercontroller.cpp
void ATDPlayerController::ServerSetDestination_Implementation(const FVector DestLocation)
{
APawn* const Pawn = GetPawn();
if (Pawn)
{
UNavigationSystem* const NavSys = UNavigationSystem::GetCurrent(this);
float const Distance = FVector::Dist(DestLocation, Pawn->GetActorLocation());
if (NavSys && (Distance > 120.0f))
{
NavSys->SimpleMoveToLocation(this, DestLocation);
}
}
}