Hi, i have a problem with handing an array, which contains class descriptions, from client to server.
In multiplayer for our game, one of the first thing that happens when a client joins a server, is that the client sends a description of its selected team to the server.
This team description contains an array of units, as defined by this UStruct class:

The problem is the TemplateClass
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Unit)
TSubclassOf<AUnitPawn> TemplateClass;
This class description will only be replicated if the server has chosen the same AUnitPawn class, else the spot in the array will be empty. So if the server does not allready have a reference to the class object, it will not be able to get/understand one handed over the network.
Is this a bug or a feature, and how should i work around this problem?
Kind Regards
Jens-Emil K.
Just for information i have made a temporary hack solution where i just keep an array in my gamemode with a reference for all unit classes. This is used for nothing other than making sure the server has a reference to the classes.
This is not a very pretty solution an requires you to maintain the array when you add new classes.
Hello Vejgaard,
Can you try using the “Replicated” specifier for the UPROPERTY declaration for this variable that is giving you trouble? I’m not seeing any other things that could obviously be causing this problem at the moment.
It’s a bit tricky since the variable is located in the GameInstance class which doesn’t get replicated. This is why i have this system of calls to pass it to the server. I might try some testing on it Monday.
I have now tried to use the replicated specifier but it did not make any difference unfortunately. As i wrote earlier the variable is located in the GameInstance class and will therefore not replicate from client to server.
Maybe you missed includes for derived subclasses of AUnitPawn. I mean if server takes one, then you create for it exactly that pawn which already has included *.h file, but in other case there maybe situation where server just doesn’t have needed definitions?
Hmm…i see what you are saying, but I’m a little unsure of the implications for us:
In our project all the subclasses of AUnitPawn are Blueprints and are loaded from a savefile in the menu and then brought over to a multiplayer match through the GameInstance class. (at which point we do the code above to sync from client to server).
So the class definition are for Blueprint classes and I don’t really know how UE4 handles these… I guess if they are compiled at runtime or something like that, then they wouldn’t be known to the server when the specific map is loaded?
As I can see ServerUpdateBattleDescription RPC is located inside BPBattlePlayerController, so you could try include needed *.h files inside its parent class, or if BPBattlePlayerController derives exactly from APlayerController, you could try derive it from custom c++ PlayerController type which includes definitions. I’m not sure at all that it’s right workaround, but you can give it a try.
Thanks for the suggestion. I think our PlayerController c++ class already should have included what is needed. I will check it out tomorrow and give it a spin if there should be something missing (Europe time, so I’m at home now
)
Hello Vejgaard,
Are you still experiencing this issue or was alkohol’s solution able to assist you? Could you let us know how the solution worked for you? In the meantime, I’ll be marking this as resolved for tracking purposes. Please feel free to comment to reopen the question so that we can continue if you’re still having difficulties.
Sorry for the late feedback. The solution alkohol gave unfortunately didn’t solve our problem.
I’m still looking into this issue. I just wanted to let you know that, despite the silence, I haven’t forgotten about this issue. I’ll let you know as soon as I have any more information on the subject.
If FUnitDescription is being used as an RPC parameter, you shouldn’t need to do anything else.
The only thing I can think of is that the server isn’t able to resolve the class name unless it already has it loaded. This is telling me these aren’t native classes, or classes that are found on disk.
Can you look at the log on the server when it fails, and look for things like “UPackageMapClient::InternalLoadObject: Unable to resolve default guid from client”?
If you could post the log here, that would be even better 
Sorry for the issues, but hopefully we can resolve this!
Hello Vejgaard,
Are you still experiencing this issue? If so, can you take a look at John’s post above and provide the information he requested?
Hi, sorry for the slow feedback, we are in the middle of a Kickstarter and time has lacking. I will try to check it out this week.
That’s no problem, priorities as always. Whenever you have time, just let us know. I’ll mark this as resolved in the meantime for tracking purposes. Whenever you are ready and leave another comment, it’ll reopen for correspondence.