Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

DateTime object not replicating from server GameState to client GameState

My GameState is configured so the instance on the server continually updates a game clock DateTime object. Although the clock ticking is working perfectly on the server it is not replicating the updated DateTime object to the client. I don't know if this is because I am reassigning the variable to a new object instance which may be breaking replication?

Here's my GameState.

alt text

alt text

Here's my UMG widget that is using the Game State replicated date time object. The result of calling GetHourMinutes is "0" which is the default value in the above Make Timespan. I launched PIE using the dedicated server option so the screenshot below is of a client connection.

alt text

alt text

When I run PIE without dedicated server so I play the game as client and server the result of the print string is below.

alt text

Here's my GameState game clock variable.

alt text

This is the GetClockMinutes function in the GameState.

alt text

Product Version: UE 4.11
more ▼

asked Jun 05 '16 at 07:29 AM in Blueprint Scripting

avatar image

689 23 22 54

avatar image vanlacke Jun 05 '16 at 07:40 AM

Can you show GetClockMinutes

Also, why not un-replicate the time variable (seems uneccesary from what you've shown) and directly grab it from the gamestate and update your clock widget that way? Worked fine when I just tried it

avatar image elitereloaded Jun 05 '16 at 08:02 AM

Thanks for your time in helping me figure this out. See my comments on the below answer ( I posted more blueprint pictures).

avatar image elitereloaded Jun 05 '16 at 08:03 AM

Also, my GameClockHud widget is already doing what you recommended.

(See my above question or click the link below)


(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

After some more testing, it turns out that DateTime does not replicate properly.. It seems to be a known bug.

For the meantime, here's what I did as a workaround. Works great

alt text

alt text

Of course you wouldn't want to call this every tick. I would suggest having the server/client sync up, and have the client independently change the clock, with checks from the server every so often. (And really you'd want to do it this way to save bandwidth usage even if datetime was replicating)

_gamestate.png (56.1 kB)
_umg.png (97.2 kB)
more ▼

answered Jun 05 '16 at 08:44 AM

avatar image

1.5k 65 132 103

avatar image elitereloaded Jun 05 '16 at 08:53 AM

Do you have any good articles that outline this design approach you are recommending?

I'm not sure how I could achieve this without using event tick in the game state.

avatar image vanlacke Jun 05 '16 at 09:02 AM

Nope, no reading material sorry. :(

Here's how I'd do it:

Server: Independently is keeping its time variable up to date.

Client: Independently is updating its clock. Every [x] amount of time, lets say 2 minutes, it will set its clock to the server clock.

For example, client logs in: Gets server time... Then every [x] amount of time it will call that function to get the current server time. You just went from sending data every second to every x minutes.

This would save a lot of bandwidth over time.

EDIT: actually, you could probably just google "network optimization" to get some good reading done

avatar image elitereloaded Jun 05 '16 at 09:29 AM

Would you store the game clock in GameMode and client requests to GameState on the server would go to GameMode to get the updated time?

GameState class is set to replicate by default. Wouldn't that replicate all the properties of GameState or only the ones that are marked to replicate? In other words if the game state object is set to replicate wouldn't it send the game clock data every tick anyways.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hey there Elite,

I think your on the right track, because of the using "make timespan" and your not carrying all the values across from the "old" variable.

But instead of doing it that way, why not use the node "Set Member of XXXX". Then you can wire in the variable you are using, and set the seconds value, with everything else being maintained as is, instead of creating a new TimeSpan object.

Here's a link to my blog, where I describe it.


Hope this helps,


IceWare Inc.


more ▼

answered Jun 05 '16 at 07:39 AM

avatar image

1.4k 41 28 56

avatar image elitereloaded Jun 05 '16 at 07:54 AM

I'm not seeing the "Set member ... " node(s). Do I need to create a custom structure and use that instead of the built in DateTime structure?

avatar image elitereloaded Jun 05 '16 at 07:59 AM

Ok, I just changed the BP to this and it still does not work :(.

alt text

The updated DateTime object does not seem to replicate.

alt text

avatar image elitereloaded Jun 05 '16 at 08:01 AM

Sorry for the triple posting.

For completeness, here's the GetClockMinutes method in the GameState object.

alt text

avatar image jayice Jun 05 '16 at 08:14 AM

I just saw that as well, that the node is not present for the TimeSpan, and was thinking about it. You have the Add Node for the variable, hence the Make TimeSpan is not what is really being replicated. As the Make TimepSpan's

I know I hate DateTime and TimeSpan, I ended up writing my own nodes in a C++ library, and just drive everything off UTC.

Your original code, should actually be working, unless the Set node in a blueprint, is creating a new variable, logically it shouldn't be, but what goes on under the covers....

Dang, not sure how to put together a test, to try to determine this.

avatar image elitereloaded Jun 05 '16 at 08:24 AM

With my knowledge of OOP, if you reassign a brand new object to an existing variable (in my case I am), then the new object has a different memory address pointer. This means any code that was referencing the original object address location will no longer receive the updated object.

Now, that is my knowledge of OOP. My knowledge of how UE4 replication works, well, I have none :). I don't know if UE4 is smart enough to see that "oh this variable is now pointing to a completely different object, let me replicate that".

Darn, I was really hoping to avoid creating a custom date time structure... I guess I can create a custom one and see if I can get it to work. Will post back here shortly.

avatar image jayice Jun 05 '16 at 08:27 AM


But your also fighting something else, or rather we both are. Yes, there are the mechanics of OOP,

But this is Blueprints, which are run by a VM, like any other P-Code language if you will. So what is Blueprints doing under the covers.....

One would hope, that it's not allocating (with the resultant deallocation, for the old object), merely because the variable's value has changed, that's what variables do for gosh sakes, they change! lmao

avatar image elitereloaded Jun 05 '16 at 08:31 AM

I believe I found [another] bug in the UE4 editor. I created a custom blueprint structure called DateTime with the same exact structure values as the native UE4/C++ one. Now my project crashes when ever I try to do anything with it or rename it lol.

There's got to be an explanation why this DateTime is not replicating... Should I file a bug report? I don't know if the UE4 development staff is active on this answers site.

avatar image jayice Jun 05 '16 at 08:39 AM

oh good grief @ project crashing

But Yeah, I preface all C++ Structures with IWS (IceWare Structure), as well as functions with IWxxxxx (where XXXX is the subsystem, like Mat for Materials, etc). Trying to keep away from all name collisions, etc.

I would file the bug report for the replication. In that your original code to me should be working, as your doing just an Add/Set sequence. Logically and mechanically you have no control over the Variable, whether it's being created/destroyed or just merely updated (one can only hope it's just being updated). But as you have no control, then Epic to me, is taking it upon themselves to ensure no matter how the variable is being altered, it's still able to be replicated (assuming you have done everything needed to replicate a value, and I have no reason to think you haven't).

There are representatives (Matthew, Stan, etc. and yes there's more than just two! lol) here from UE4 to address this concern. Just be sure to put it under Bug Report/Crash etc, so it doesn't get lost in the weeds.


IceWare Inc.


avatar image elitereloaded Jun 05 '16 at 08:41 AM

I just tried assigning the Minute structure pin to it's own variable in GameState and then rewired my GetClockMinute function so it pulls the new GameClockMinute variable. The game clock UMG widget is now receiving the updated clock minute, so it's definitely an issue with replicating the DateTime object :(... Or at least my design approach for replicating it.

alt text

alt text

alt text

avatar image jayice Jun 05 '16 at 08:43 AM

File away Sir, File away... Let em know.


IceWare Inc.


avatar image elitereloaded Jun 05 '16 at 08:50 AM

Thanks for your help in giving me reassurance that although I'm 1 week new to this I have a good understanding of multiplayer replication. I'm sure I will see you around!

avatar image jayice Jun 05 '16 at 08:51 AM

Have a good one!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question