Announcement

Collapse
No announcement yet.

GameInstance doesn't support Switch has Authority?

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

    GameInstance doesn't support Switch has Authority?

    I'm trying to switch on authority in a game instance function, but the Switch Has Authority node is not available.
    The documentation for GameInstance says that game instances are created once per client, so it's not server-only: https://docs.unrealengine.com/latest...nce/index.html
    The "crash course in networking" says that I should turn on replication for a blueprint in the "Replication" defaults panel. However, this gameinstance blueprint does not have such a panel: https://www.unrealengine.com/blog/cr...ts-replication

    I'm using a RepNotify variable, and in the OnRep_ function, I want to load a new level if the variable changes, only if I have authority.
    How can I do this?

    #2
    The GameInstance class only exists for clients, therefore you cannot distinguish code paths into Authority or Remote. GameInstance does not replicate.

    Try doing your level changing within the GameMode class.
    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
      The GameInstance also exists for the Server, but this is his own. The part with the replication is correct.

      Plus, the GameMode only exists on the Server! Keep that in mind.
      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


        #4
        Are you sure GameInstance does not replicate? I am using it to store variables between all players, and it seems to work.
        Marketplace Assets

        Advanced Mobile Input: Marketplace Page | Support Thread ――― Easy Input Remapping: Marketplace Page | Support Thread
        Multiplayer Blueprint Chat System: Marketplace Page | Support Thread ――― Closing Credits System: Marketplace Page | Support Thread
        Minesweeper Template: Marketplace Page | Support Thread ――― Maze Creator: Marketplace Page | Support Thread

        Comment


          #5
          Totally sure. The GameInstance is unique for each player. It is created when you Start the Game and it is not destroyed until you close the Game.
          So it is the only class (at normal settings) that survives level changes. If you debug the GameInstanceBlueprint and selected single clients, you will only
          see one single GameInstance per client/server.
          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


            #6
            If you debug the GameInstanceBlueprint and selected single clients, you will only
            see one single GameInstance per client/server.
            Yes, that's what I would expect.
            However, why wouldn't it replicate?
            I can mark properties on Gameinstance as replicated.

            Trying to do the level switch in GameMode doesn't work that well because I need to preserve state, and I need to drive it from the server.

            Also, I must be not getting something about the GameInstance.
            The "event init" that is a default event, doesn't get called. (I have a print and a breakpoint; never gets set)
            When I call a custom event from the level blueprint, and the custom event tries to create a User Widget with a couple of buttons, and add that to the viewport, the viewport doesn't actually show the buttons.
            Last edited by eXi; 09-06-2015, 06:12 AM.

            Comment


              #7
              You need to set your custom GameInstance in the "Maps and Nodes" Project Settings, the same place where you set the GameMode etc.
              At the bottom there is dropdown Menu to select the GameInstance class that should be used.

              If the INIT is not called, i guess you just forgot to do what i wrote above :P
              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


                #8
                If the INIT is not called, i guess you just forgot to do what i wrote above :P
                I believe I have set the class correctly. Also, I don't think that's the problem, because in the level blueprint, I can cast the game instance to my game instance subclass, and call an event directly.
                My work-around was to do just that.
                However, when doing that, the UI that was created was still not attached to the viewport.
                I'm wondering if this happens too early in the setup of the game or something.

                I'm git cloning the code now so that I can answer these questions with authority.
                It's amazing how little is actually answered in the reference manual. Try looking up "GameInstance" and then see if it's replicated or not. (Not documented on that page)
                Try looking up "GameMode" and see when an instance will be created an destroyed. (Not doumented there)
                Try looking up the difference between "Open Level" and "Server Travel" (the latter doens't even have a Blueprint Node)
                The documentation seems to document the ******** that I can already deduce from the names of things, and none of the important bits like "when is this constructed, who owns it, how does it fit into the bigger scheme of things."

                Comment

                Working...
                X