Hey there,
I made a PlayerController for TouchScreens and now want to use it in Multiplayer games. I just began with the Multiplayerstuff, so my question should be an ultimate basic one
When I try to move my current PlayerCharacter it is jumping back all the time. The reason for this should be that the Character isn’t moving on the server. So i set up the following Code:
Header:
UFUNCTION(Server,Reliable,WithValidation)
void SetLocationOnServer(FVector Location);
.cpp
void ATouchController::SetLocationOnServer_Implementation(FVector Location)
{
if (HasAuthority())
{
APawn* Pawn = GetPawn();
Pawn->SetActorLocation(Location, false, nullptr);
}
}
bool ATouchController::SetLocationOnServer_Validate(FVector Location)
{
return true;
}
In the Eventfunction bool ATouchController::InputTouch
I start the function by: SetLocationOnServer(PlayerCharacter->GetActorLocation() + 1500 * MovingDirection3D);
While PlayerCharacter is a Pointer to the PosessedPawn on the client.
Thanks for your help