Blueprint Class Id Variable not set on dedicated server

Hi all,

If I have a character blueprint that has a Class variable (so a UClass* under the hood), set that variable just through normal means (not at runtime or anything, simply exposing the variable and setting it through the editor) - the variable will not properly be set on a dedicated server. Listen server is fine.

To illustrate this, I added a simple Print String in On Begin Play in the Shooter Game example and had it just do a “Is Class Valid check” on the variable to verify this and sure enough:

[2017.03.29-02.36.51:873][454]LogBlueprintUserMessages: [FirstPersonCharacter_C_2] Server: false

Despite that the same logic returns True on a Listen server.

Any thoughts?

Hey ExtraLifeMatt,

So I’ve tested this in Shooter Game. Here was my process:

  1. Created a new actor
  2. Added an actor class variable and set it to Editable and Expose on Spawn
  3. Added it to the level
  4. Set the class variable on the instance of the actor
  5. On the actor’s begin play, printed the name of the actor to see if it was null
  6. Played in a new window with 2 players and Run Dedicated Server checked

Let me know if I missed any steps or did anything differently than you.

My question is, are you using a dedicated server that you built, or are you just using the Run Dedicated Server option in the editor?

Thanks

Hi Sean,

Thanks for checking this out.

The only thing I did differently from you is use the Is Valid Class method rather than just trying to print the class name. I’m running with just the Run Dedicated Server option turned on, there isn’t a specific server build.

The class I’m using as a variable is also contained in a plugin, so I’m concerned that maybe there needs to be a special target for a dedicated server - but it seems to be loading at least all the blueprint methods contained by the plugin. Just the serialized class data doesn’t appear to be loading when running with that option (which works fine when using a listen server).

Also I can provide a project that shows this behavior if you’d like to PM me.

Could you do me a favor as well and try to follow the steps I outlined above to see if you run into the same issue?

The reason I ask is because if the issue is coming from something that is contained in a plugin that isn’t official, this isn’t something that we can offer support for, unfortunately. Is the plugin something that you’ve created yourself?

I was able to reproduce the behavior I’m seeing with just a normal class(ACharacter). I’ve included an image with the setup:

Image

And yes this is occurring with a plugin class I created as well (so its a bit of relief it happens in basic classes too).

EDIT: If you notice the output log you can see the “False” being printed (ignore that there are two. I initially had this chained with the field I was originally testing to check things side by side but removed that node to clean up blueprint for you).

Thanks for the information. I’ve tested this again in ShooterGame, and I still notice the variable reference returning true.

This time, I created my own actor class (testActor) on top of the one I had earlier, placed that in the level, and then set the variable to reference that actor’s class (testActor). On BeginPlay, the server and both of the clients I was using returned true.

Is it possible that it could be an order of operations issue? Try adding a short delay after begin play. It’s possible that the server tries to grab the variable before it’s been fully initialized. Let me know the results after you add the delay.

So, if I add a 2 second delay, the 2nd character (0 based) that is instantiated has the field and it’s fine. The next time the object is instantiated, the field is not fine.

LogBlueprintUserMessages: [FirstPersonCharacter_C_1] Server: true
LogBlueprintUserMessages: [FirstPersonCharacter_C_0] Server: false
LogBlueprintUserMessages: [FirstPersonCharacter_C_2] Server: false
LogBlueprintUserMessages: [FirstPersonCharacter_C_1] Client 2: true
LogBlueprintUserMessages: [FirstPersonCharacter_C_2] Client 2: false
LogBlueprintUserMessages: [FirstPersonCharacter_C_0] Client 2: false
LogBlueprintUserMessages: [FirstPersonCharacter_C_1] Client 1: true
LogBlueprintUserMessages: [FirstPersonCharacter_C_2] Client 1: false
LogBlueprintUserMessages: [FirstPersonCharacter_C_0] Client 1: false

I should note I’m using 2 players, Run as Dedicated Server and with New Editor Window turned on. If I turn off Dedicated Server, everything works properly. So weird.

Ah, I get what you are saying. That makes sense. Thanks Sean!

After further investigation, I do not believe that this is a bug. The reason for this is because you’re setting the exposed variable on the instance of the class that exists in the level. When connecting to the dedicated server, the server likely spawns another instance of the pawn that does not have this variable set, which would lead it to be considered invalid.

In order to test this, I removed the editable and expose on spawn properties from the variable, and instead set the default value in the blueprint itself. When you do this, you’ll notice that the variable is valid on the server and the clients as well.

Let me know if you have further questions.

Have a great day