Assets and Networking

Hi. I’ve been testing with replicated references to assets.

I hope this doesn’t only work, because it’s PIE, but I was able to replicate an actor’s UObject-pointer to any asset that already exists before runtime. I am even able to call multicast functions on them.

But there’s one big problem I need a solution for. I need to create new assets and runtime, and I need replicated references and multicasts to them.

But I can’t replicate an asset. To my knowledge only actor-derived classes can do that. And by doing so, the engine automatically knows that two actors “belong together”.

Is there any way to tell the engine that an asset created on one machine is the counterpart of an asset on another machine? There has to be something or it wouldn’t work with “static” assets. Help please!

I don’t know how you generate those assets and what for so not sure if this solution is good, but maybe try using assets IDs insted of objects

https://docs.unrealengine.com/latest/INT/API/Runtime/CoreUObject/Misc/FStringAssetReference/index.html
https://docs.unrealengine.com/latest/INT/BlueprintAPI/Utilities/ResolveAssetID/index.html

Thing is you would need to make code which would generate same asset with same ID in any client if needed.

Alternaticly if you talking here about user generated content maybe use structs with data about that content and replicate struct which client will be able to recreate that content in to asset

The assets are a kind of body-morph descriptor. The reason I wanted them to be assets is that I wanted to have the choice whether they are “persistent” assets made and saved in the editor, or dynamically created transient objects made procedurally at runtime.

I’ve been thinking about the right approach for days, and last night I experimented with replicated asset pointers for hours. It seems possible now, if you use the right flags on the assets, create them on all machines and make sure they are “stably named”.

But the biggest problem is that I can’t properly test what I’m doing. Apparently, in PIE the asset folder is shared among all simulated instances. So it’s possible to create an asset only on the server and reference the same object on a client. Multicasting doesn’t seem to work, if the object exists only once. But I can’t create another one for each client, because it would have to get a different name, which would brake replicated pointers and multicasting afaik.

I’m not sure if this is only true for the “single thread” option. But I tried a lot of things last night, with single thread checked and without it.

I guess I will just use actors now…

I think you tie yourself too much to assets and trying to replicate them, most impotent thing is is raw data and it does not matter if it will be asset or not and how you send it (UE4 replication, HTTP etc.), you can always produce or reconstruct anything out of data. If you see limits of UE4 then think out of the box, for me use of AActor just for data it seems to be overkill compared to more lite methods you could use… like using structs as a descriptor

Can a struct replicate by itself?

Because right now, I create a body-actor without any components but a body-descriptor-struct that gets replicated as a whole through the actor. Every client can use this data to create procedural meshes from it. That’s the best I could come up with…