[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

… Uh… where did my other two posts go?

This was a useful piece of code - if I remember it right?
Why not ping Victor and post a quick BUG report here.
Otherwise, this may not ever get noticed / fixed dude! :wink:

Will do!