I am currently developing a multiplayer prototype, via a listen-server.
In the game, the player is able to enter/exit vehicles, and this is where it goes wrong:
After interacting with the vehicle (client-side) a function gets called on the player controller, that executes on the server (ServerEnterCar), which on its turn calls a function on the clients via multicast (ClientEnterCar).
This logic works completely fine when it is called from a client (so not the server client)
but when it is called from the server client itself, it is not being executed on the other clients.
Controller.h
void TryEnterCar(AMyWheeledVehiclePawn* InPawn);
UFUNCTION(Server, Reliable, BlueprintCallable)
void ServerEnterCar(AFreeroamPlayerController* controller, AMyWheeledVehiclePawn* InPawn, APlayerCharacter* InPlayerCharacter);
UFUNCTION(NetMulticast, Reliable, BlueprintCallable)
void ClientEnterCar(AFreeroamPlayerController* controller, AMyWheeledVehiclePawn* InPawn, APlayerCharacter* InPlayerCharacter, bool setAsDriver);
UFUNCTION(BlueprintImplementableEvent)
void ServerEnterCarBP(AFreeroamPlayerController* controller, AMyWheeledVehiclePawn* InPawn, APlayerCharacter* InPlayerCharacter);
UFUNCTION(BlueprintImplementableEvent)
void ClientEnterCarBP(AFreeroamPlayerController* controller, AMyWheeledVehiclePawn* InPawn, APlayerCharacter* InPlayerCharacter, bool setAsDriver);
Controller.cpp
void AFreeroamPlayerController::TryEnterCar(AMyWheeledVehiclePawn* InPawn)
{
if (!PlayerCharacter)
{
PlayerCharacter = GetPawn<APlayerCharacter>();
}
if (PlayerCharacter)
{
ServerEnterCar(this, InPawn, PlayerCharacter);
}
}
void AFreeroamPlayerController::ClientEnterCar_Implementation(AFreeroamPlayerController* controller, AMyWheeledVehiclePawn* InPawn, APlayerCharacter* InPlayerCharacter, bool setAsDriver)
{
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("CLIENT: ENTER CAR"));
ClientEnterCarBP(controller, InPawn, PlayerCharacter, setAsDriver);
}
void AFreeroamPlayerController::ServerEnterCar_Implementation(AFreeroamPlayerController* controller, AMyWheeledVehiclePawn* InPawn, APlayerCharacter* InPlayerCharacter)
{
ServerEnterCarBP(this, InPawn, PlayerCharacter);
}
Thanks in advance for the help!