I have used the JSON blueprint utilities plugin to create an inventory system. The system is fully replicated. However I am coming across a few issues in using this plugin…
1.) The JSON object variables are not cleared immediately after each PIE session.
2.) The JSON object variables are not replicating correctly.
3.) The JSON variable acts like a singleton object during a PIE session.
So now Im curious whether I’m just using these objects wrong, or if this feature is just entirely not ready for a beta release.
I found a workaround that seems to have solved all issues. Currently I am creating a JSON object wrapper, and setting my variable to that on begin play. That seems to take care of the shared JSON object issue. Also I am converting the JSON object into a string on the server, replicating the string, then converting the string back into a JSON object on the client.
well, without really knowing what you’re doing as far as the blueprint goes… yes, they are terrible, but that doesn’t mean you’re not confused also
I’m curious what would lead you into building a system based on JSON in Unreal, as it doesn’t have particularly easy to use JSON support, and JSON isn’t designed for replicating in high speed networking conditions (considering it’s human readable text, it’s probably not a great choice for a system where keeping the amount of data transferred light is usually preferable!) … I would expect to use JSON to interact with remote services, especially web-based services, REST APIs, things of that nature. I could also see a use for it for storing data to disk, or outputting it to other places … but i don’t see value in using it for an internal system that is replicated.
Those are good points. The main motivation for using JSON was that not all inventory objects follow the same structure. My initial thought behind keeping the inventory data in a JSON object while in game was that the load on the server could be reduced by
1.) Not needing to regenerate the JSON object each time the inventory saves.
and
2.) Not needing to spawn a large number of actors each time a player logged in
I guess since each item is represented in a standard way regardless of their class, it would make sense to only replicate the items needed to the client though.