What am I trying to achieve?
I have a multiplayer project that I’m in the prototyping phase.
I’d like to know if there is a way to package assets: not with a specific platform but a specific build target.
Specifically, I’d like to Send a BP Function Library with my server that has some [Logic] in it that the client doesn’t have access to. From The server can call functions from this library or libraries if this is possible.
There are some mysteries when it comes to the compilation of BP’s and Packaging of assets so if I seem confused about this process it is in these areas that I lose the plot.
I hadn’t thought about it until a few days ago when I asked myself the question:
How do I write exclusive game logic for the server that’s not a gamemode or gamestate but the client shouldn’t have access to? For example. To use some ability in a character class. The logic for the ability shouldn’t be in the clients Character. Just a way to target who, when, where, and how and a method for a request to use that ability.
I considered the following approaches (after leeeengthy thought):
Method 1: Swap the default project wide game instances during packaging:
I create two separate GI_Blueprints.
Client_GameInstanceBP gets packaged with the client.
Server_GameInstanceBP gets packaged with the server.
I could write BP_logic for the server. The server game instance shouldn’t care about the client game instance. However, I was unsure about:
a. RPC’s and what actually happens when you make an RPC (how are the constructed under the hood).
b. What happens if you replicate a variable to client that it doesn’t have??
Would the server crash? Or The client? Or would nothing happen? “Accessed_None”?
Method 2. Make a Parent GI that has variables that are replicated and all the events and RPC’s.
I’d Create & Package children of this parent GI, again one for the Server and one for the Client.
Adding logic only in the derived Server GI.
However I was unsure if:
a. Replication is or can be inherited between classes?
b. How a variable set to replicated, that was inherited, would behave because I don’t know what exactly happens that makes variables replicate under the hood of the engine.
c. This also applies to replicated events.
Method 3. (Best): Send a Function Library unique to the server:
I’d leave the GameInstance for the project the same in both packages.
Add all replicated variables needed to this one singular GameInstance.
Construct, “end-points”, for RPC’s.
I’d uniquely send a function library with the Server package such that the server only has the logic to manipulate the variables or execute whatever functionality I want.
Construct RPC (Client>Server) endpoints such that they only amount to a request.
I can pass this request through some sort of validation check/layer on the server and determine, if it’s permissible within some bounds, to execute some other function that ultimately would also be an RPC.
This seems like the right idea? I think…but I am not sure how to do this with BP’s?
If there was some:
#ifdef with_server_package
BP_FunctionLibrary.uasset
#endif
or maybe some way to exclude an asset(s)? from a package??
I don’t know if this is something that needs to be done with UAT?
or an Editor utility Bp?
Guidance is really appreciated here.
Bartender by day…Aspiring Game designer by night (so work with me)