Announcement

Collapse
No announcement yet.

Spectator pawn on client side

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    I've found a clue. bIsSpectator is replicated after the change state to spectating.
    A really dirty solution is to add a delay before change state to spectating after set bIsSpectator to true.

    Code:
    void ASPlayerController::SetSpectatorState()
    {
        PlayerState->bIsSpectator = true;
        // Waiting IsSpectator replication before set state spectating
        FTimerHandle TimerHandle_Tmp;
        GetWorldTimerManager().SetTimer(TimerHandle_Tmp, this, &ASPlayerController::WaitingForChangeState, 3.f, false);
    }
    
    void ASPlayerController::WaitingForChangeState()
    {
        ChangeState(NAME_Spectating);
        ClientGotoState(NAME_Spectating);
    }
    I don't like this solution. That cause some ploblemes if the player respawn during the delay for exemple.

    Another solution would be, in the OnRep_IsSpectator, the client tell the server to set him state spectating. I haven't test it at this time. But I'm not sure the replication of bIsSpectator is the real or only cause.

    Leave a comment:


  • started a topic Spectator pawn on client side

    Spectator pawn on client side

    On a player death, I try to set the controller state to Spectating. I have made my own BP_SpectatorPawn Inherit from ASpectatorPawn and configure the game mode for use it.

    In the player character death function, I call a controller function SetSpectatorState just after a DetachFromControllerPendingDestroy():

    Code:
    void ASPlayerController::SetSpectatorState()
    {
        PlayerState->bIsSpectator = true;
        ChangeState(NAME_Spectating);
        ClientGotoState(NAME_Spectating);
    }
    It work fine on the server player death. But the SpectatorPawn seams to be the default SpectatorPawn on the client and it's created at 0,0,0 instead of the current view location. The game state seams to replicate correctly the Reference to the SpectatorPawn class. I don't understand why the client have this comportment.
Working...
X