Hi guys,
I have been attempting to learn multiplayer to develop myself, I think I understand RPCs and generally the basics.
I am stuck right now trying to dynamically spawn in a character (based on a selection) and make that player possess it. E.g:
Player 0: Selects Character A.
Player 1: Selects Character B.
I have a timer running on the server, once it reaches 0, it runs a function on the Server to update all the player controllers. This calls a function running on the clients player controller to hide their character select widget, once done, inside that function, it attemps to create a character and possess it. For the sake of getting the spawn and possess thing figured, I am not doing anything with the selected characters (just spawning a basic third person character).
The server successfully spawns a character for itself and possesses it, but not the client. I can’t figure out why?
Right now when reaching the spawn/possess it calls a function on the server that runs a client rpc which spawns/possess the character. I tried also with multi casts but it doesn’t work either.
Function on the game mode called when the timer is 0.
void ADuelingGameMode::RS_OnTimerOver_Implementation()
{
for (auto Element : m_apcAllControllers)
{
Element->RC_TimerOver();
}
}
which calls:
void ADuelingController::RC_TimerOver_Implementation()
{
... removed widget, sets input mode.
RS_SpawnCharacter();
}
which is:
void ADuelingController::RS_SpawnCharacter_Implementation()
{
MC_SpawnCharacter();
}
and finally:
void ADuelingController::MC_SpawnCharacter_Implementation()
{
const FVector& spawnLoc = FVector(100, 100, 100);
AProject_ArenaCharacter* Char = GetWorld()->SpawnActor<AProject_ArenaCharacter>( PCharacter, spawnLoc, FRotator::ZeroRotator );
Possess( Char );
}
the location and character is all temporary for the time being.
Can anyone tell me where my logic fails and what I am doing wrong?