Announcement

Collapse
No announcement yet.

Multiplayer related questions.

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

    Multiplayer related questions.

    Not sure this is the correct section, but all in all there isn't a "multiplayer" subforum..

    So, I'm trying to setup my singleplayer game in a way that stuff I do will be later already easy to translate to a multiplayer game.

    Now, I'm trying to set up the rules for my game.

    From what I understand Game Mode only exists on the server and is not replicated.

    This contains stuff like handling player connections and logins.

    So:

    1) how does client A knows that client B connected?
    Does it happens because a pawn is spawned for player B and his score/stats are inserted and replicated?
    And lets say that client B does nothing, like connecting to a counter strike server, should I assign a state spectator automatically to the player so he's replicated as a spectator for all clients?

    2) Lets say I want to make a gamemode that consists of capturing a flag, first who captures a flag wins the game.
    Should the process be to create a flag actor that replicates and create a rule in game state that states that if actor has a certain value (example uncaptured = 0, captured by team 1= 1, captured by team 2=2) so 1 or 2 game ends? So basically, e.g. :

    team 2 captures the flag, the news is replicated to all clients through game state-> GameState sets a variable bGameIsDonezo in GameMode which changes map->game mode changes gamestate to replicate map change on playercontrollers?

    3) Let's say I want to handle the various states of my game through enums:
    0-pre game (no pawn is assigned till everybody chooses a team and class)
    1-warmup (pawns are assigned, but actual game is not)
    2-game (all pawns are destroyed and reassigned, game starts tracking points and stats)
    3-game ending (all pawns have their movement blocked, they can't shoot, everybody can vote the next map)
    4-changing level (after everybody voted, the map is changed)

    Where should those states live? Game mode or game state?

    I hope I was clear as much as possible.
    Last edited by Aquazi; 02-25-2016, 02:31 PM.

    #2
    Singleplayer games are still technically Multiplayer since the game even in SinglePlayer is still running as a Server. In SinglePlayer the player is the Host/Server.

    GameMode only exists on the Server that is correct.

    GameMode handles player connection/disconnection through 2 events. OnPostLogin and OnLogout, these are only called for Clients, if you were running as a non dedicated Server, the Host Player would not receive these Events since it is the Server already and has a PlayerController to begin with.

    1. Players do not know about each other explicitly, they must query the Server. Using OnPostLogin in the GameMode, you can easily notify other Players that someone has just connected. There is an Option on the GameMode class called bStartPlayersAsSpectators. This will assign the recently connected PlayerController a SpectatorPawn by default, otherwise they will spawn with a DefaultPawnClass.

    2. A flag in CTF can have a few states, in my GameTypes Marketplace package (link in my Signature) i manage the states of the Flags on the Flag Actors themselves. When a Flag has been captured, i notify the GameType which then decides if the Game is over or not.

    3. My GameState class has a MatchState variable Enumeration that is modified by the GameMode on the Server.

    I hope these cleared up your questions for you.
    Im an Moderator on UnrealSlackers Discord! Which is a Community driven group of likeminded people here to discuss UE4! Join UnrealSlackers on Discord!

    Comment


      #3
      What manages a map change after game is finished?

      I imagine gamemode changes playercontrollers to change level?

      When a Flag has been captured, i notify the GameType which then decides if the Game is over or not.
      Shouldn't the server change the flag state?
      Last edited by Aquazi; 02-26-2016, 11:18 AM.

      Comment


        #4
        Originally posted by Aquazi View Post
        What manages a map change after game is finished?

        I imagine gamemode changes playercontrollers to change level?



        Shouldn't the server change the flag state?
        The GameMode changes the Map. The PlayerControllers just travel to the next map set by the GameMode, this is done automatically when you call for a map change.

        The Flags that exist on the Server are the relevant Flags, the ones that exist on the Client are only for visuals as everything is done Server Side.
        Im an Moderator on UnrealSlackers Discord! Which is a Community driven group of likeminded people here to discuss UE4! Join UnrealSlackers on Discord!

        Comment


          #5
          Not saying you can't handle the "MatchState" in the GameMode, but i would handle that in the "GameState" class.
          Since that is the class which is actually made to handle the MatchState.

          Your Replicate flag will only have logic on the Server side. The only stuff you pass to the client is maybe a position change
          or color change, what ever you need.

          If the flag is captured, the SERVER SIDE of the Flag tells the GameState "Hey, i'm the red flag and i was captured by XYZ."
          The GameState then can multicast updates to the clients, so you can have visuals showing up in the UI saying "XYZ has captured the red flag."
          Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

          My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
          (Including 100+ Pages Multiplayer Network Compendium to get you started.)

          Comment

          Working...
          X