channeldorg / channeld-ue-plugin

Enables distributed simulation with Unreal Engine's dedicated servers. 为虚幻引擎专用服务器提供分布式模拟能力的开源插件.
Apache License 2.0
132 stars 38 forks source link

Optimize UnrealObjectRef #34

Closed indiest closed 6 months ago

indiest commented 1 year ago

UnrealObjetRef carries a NetworkGUID to reference an UObject between UE clients and servers. A Fully Exported UnrealObjectRef (FER) also contains the outer object chain and serialized bunch, in order to spawn the actor. Depending on the length of the outer object chain, the size of a serialized UnrealObjectRef varies from 100 to 300 bytes.

FERs exists in both spatial and entity channel data. Whenever a connection subscribes to an entity channel, or a handover happens, FERs are sent to the interested sides, and the network traffic overhead is considerable.

To improve the network traffic, ChanneldUE should have its own framework to replace UE's SerializeNewActor. The classPath field was an attempt, but it doesn't work in some scenarios. An ideal solution would be building a type map and maintain the map distributedly. In that way, only the type key is need in the UnrealObjetRef to spawn actors in most cases.

laughxing commented 1 year ago

Currently object is replicated using UnrealObjectRef, but only dynamic object is supported. Static Class or resources also need to be supported, for example TSubclassOf in function void ClientSetHUD(TSubclassOf<AHUD> NewHUDClass) or UStaticMesh in https://github.com/metaworking/channeld-ue-plugin/issues/32.

A global map for all static objects seems a possible solution.

indiest commented 6 months ago

With the StaticGuidRegistery in v0.7.3, the UnrealObjectRef won't have to be fully exported in most cases.