Download

Networking Questions

Hello Everyone,

So I am currently trying to make a Top-Down Shooter using UE4 and am having a little problem understanding the network side of things.

Couple questions

  1. How do I handle movement, should it be sent thought the server or locally on the clients?
  2. I have been reading the documentation on https://wiki.unrealengine.com/Networking/Replication but I dont really understand what these pieces of code are for

void AYourCharacter::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);
 
    // Replicate to everyone
    DOREPLIFETIME(AYourCharacter, Health);
}


 bool bSomeBool;
 
    void SetSomeBool(bool bNewSomeBool);
 
    UFUNCTION(reliable, server, WithValidation)
    void ServerSetSomeBool(bool bNewSomeBool);


void AYourPlayerController::SetSomeBool(bool bNewSomeBool)
{
    bSomeBool = bNewSomeBool;
 
    if (Role < ROLE_Authority)
    {
        ServerSetSomeBool(bNewSomeBool);
    }
}
 
bool AYourPlayerController::ServerSetSomeBool_Validate(bool bNewSomeBool)
{
    return true;
}
 
void AYourPlayerController::ServerSetSomeBool_Implementation(bool bNewSomeBool)
{
    SetSomeBool(bNewSomeBool);
}

I just don’t know why they are used and how to use them can anyone elaborate better than the documentation? Something like Changing player speed how would I go about this I know locally it’s done through CharacterMovement->MaxWalkSpeed

Thanks as always

-Kevin