No announcement yet.

[ASSET] [TUTORIAL] Universal Get Network / Local Role

  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Dynamic widgets using this system, that shows you exactly who is what, and why. It also shows a comparison between this and "vanilla" ue4:
    Click image for larger version  Name:	DsMmZWH7k8.jpg Views:	2 Size:	362.9 KB ID:	1615218
    Last edited by EvoPulseGaming; 10-26-2019, 09:33 AM.

    Leave a comment:

  • replied
    Here you go:
    Note: I basically scrapped splitscreen demo content, there are so many issues with split screen its not even funny. There is nothing I can do about how splitscreen is handled.
    Last edited by EvoPulseGaming; 05-04-2019, 03:52 AM.

    Leave a comment:

  • replied
    Hi, thank you for your information, would it be possible for you to provide a bit more info, how and where you would place the above code, just after a bit of clarification on usage
    Maybe a small example.

    Leave a comment:

  • replied
    The setup:
    Create a blueprint Enum: Call it UniversalNetRoles

    Click image for larger version  Name:	UE4Editor_7R4vty8tRA.png Views:	1 Size:	118.1 KB ID:	1612705

    Create a blueprint function library: Call it Universal_GetRole
    Inside of it create two functions:

    "Universal Get Network / Local Role":
    Create a local Variable called Actor
    The input is OBJECT (This way, you can call it on Components and Actors, and PlayerControllers, PlayerStates, GameState)
    The output is called "Role" of type : UniversalNetRoles (The blueprint enum you just created above)

    Visit this link to see the blueprint

    "Recursive Get Owners PC"
    No local Variables needed
    The input is ACTOR
    The Output is PlayerController, and a boolean called "Bad input_or_Not found"

    Visit this link to see the blueprint
    Last edited by EvoPulseGaming; 04-27-2019, 02:40 PM.

    Leave a comment:

  • replied
    Network logic basics: (Only for the blueprint logic in post #3!!!! Autonomous and ListenServer behaves differently in vanilla UE4!!!!!!)

    STANDALONE == Singleplayer
    Note: If creating an "offline" capable network game, run both the server and client functions. (useful, if you want to have menus and stuff before joining a server.
    Special case: See INDETERMINATE

    DEDICATED: Has full authority over everything the server created, there will be a copy of everything, on EVERYONES machine (except for gamemode)
    Note: Dedicated servers are "headless" aka no GUI. No widgets, no viewports.

    SplitScreen (As Server+Client):
    You are the client in the traditional sense, you just "happen" to have server authority. We also own the clients viewport

    SplitScreen Autonomous Proxy (No Costmetics):
    We are basically a client, but we can not add stuff to the overall viewport, you will have to ask the "SplitScreen (As Server+Client)" to do this for you! (You can still add stuff to your own, "add to player screen")
    Actually, its best to always use "add to player screen" and never worry about it again... (unless you want a whole screen pause menu, or something like that, which of couse, 2nd+ player has to ask player 1 to do it for them....)

    **** LISTEN SERVER (Vanilla UE4):****
    Same as Dedicated, however you are the server AND your own client, so you can do GUI stuff, like widgets and viewports
    This is a special ownership, because you have to handle your own client's stuff as the server
    So, as the Server, you will have a "BeginPlay" for yourself, and other clients
    You will do "server" stuff at the SAME TIME you are doing YOUR "client" stuff under "Authority"
    While all other clients will do their own "client" stuff under "Autonomous Proxy"

    LISTEN SERVER (As Server only) :
    You are the dedicated server in the traditional sense. (You are handling other players stuff)

    LISTEN SERVER (As Server+Client) :
    You are the client in the traditional sense, you just "happen" to have server authority. (You are the server handling your own player stuff)

    **** AUTONOMOUS (Vanilla UE4) :****
    It belongs to you, but the server has authority. Here only "Possessed" actors, have this network role.
    Note : When you first spawn the actor, during BeginPlay, get local role, will return simulated. It's not until after you posses, that this changes to autonomous.

    AUTONOMOUS : It belongs to you, but the server has authority. You can call RPC's, but the server can override replicated variables at will.

    SIMULATED : A copy of another players stuff, that is running on your machine. You have no control, (You "technically" can change variables here, but the server can override them at any time)

    INDETERMINATE: These are actors spawned on the client side. They are non-networked actors. (Think waypoints, or "targets" or something, that the client would spawn, that no one else needs to know about.

    Special Case: Standalone : Because you are the "server" AND the "client" , you will see them under Standalone

    Special Case: ListenServer: Because you are the "server" AND the "client" you will see them under Listen Server; BUT you will only see YOURS
    Last edited by EvoPulseGaming; 05-04-2019, 02:56 PM.

    Leave a comment:

  • [ASSET] [TUTORIAL] Universal Get Network / Local Role

    New users of UE:
    You should be familiar with this first:
    UE4 Network Compendium by Cedric "eXi' Neukirchen <---Link

    This is the product of making my own game the last three years. Here the coding style is Server/Client, no matter what. It doesn't matter if its splitscreen, dedicated, or a listen server, even standalone is coded the same way.

    Write it once. As long as you stick with the idea of server/client no matter what, this blueprint function will work for you.

    Did you just say to code in Server/Client for Standalone???
    Yes, following the write it once idea, if you split up code that you could consider server/client, then if you want to move to networking, you don't have to tear your game apart.

    Okay, I wrote everything as server/client for Standalone, but you only have one output for standalone?
    Just create a sequence node, connect the "server" code first, and the "client" code second. (I could just put the sequence node into this function and call it "Standalone FakeServer" and "Standalone FakeClient"

    Why does your blueprint have different split screen and listen server outputs?
    Splitscreen for example: the first player owns the screen, you cannot add stuff to the viewport as a second+ player in splitscreen, also, (probably a bug) you cannot see widget components set to screen space on anything but the first player. So its nice to know, before you spawn actors that use this. (Code runs in background without visual feedback. Have fun debugging if you didn't know about this)
    Listenserver: Normally you have server code and client code, but as a listen server, the server IS a client, and the typical Has Authority node will not work.
    Let me explain that a bit more, say you want to spawn a menu on only the client, if you use Has Auth, then the ListenServerClient won't spawn one, because its has authority over its own client. There is a way to figure it out, but it appears to be a "bug"? that I abuse.

    Due to the way that the Autonomous role is replicated, (after spawning, after BeginPlay, after you use "posses"), or not replicated (actors that cannot be possessed, or actors that you own, but wont possess), you will have a hard time determining if you have the rights to call RPC's.

    That shouldn't matter right? Bad RPC's are just dropped!
    Yes, but go ahead and try debugging that. This function will make your life easier.

    Now, you can code around these various "ways" of networking without worrying about UE's "gotchas" and "you-wish-you-would-have-knowns"

    In the next two posts, I will leave some valuable information, and pictures of the entire setup
    Attached Files
    Last edited by EvoPulseGaming; 05-04-2019, 02:54 PM.