Adding networking functions to PangaeaGameInstance
Before we add these functions to APangaeaGameInstance
, it is important to explain why we must add these functions to this class but somewhere else.
We know that GameInstance
only exists on the client side and that the ButtonHost, ButtonJoin, ButtonLeave, and ButtonLobby buttons are pressed by players when they are playing the game on their end, so it makes sense to implement those functions that allow players to host, join, and leave games on the client side.
Now, let’s open the PangaeaGameInstance.h
file and add the following code to declare the functions in the ApangaeaGameInstance
class:
public:UFUNCTION(BlueprintCallable, Category = "Pangaea") void StartListenServer(); UFUNCTION(BlueprintCallable, Category = "Pangaea") void JoinAsClient(FString IPAddress); UFUNCTION(BlueprintCallable, Category = "Pangaea") void LeaveGame()...