UE4 Actor Replication(同步)的性能問題
看了下相關(guān)文檔,UE自帶的Replication機制效率還是很低的,UE為了提供通用的同步功能,這個Replication實現(xiàn)的非常簡單粗暴,如果是承載客戶端鏈接很多的項目,這個Replication貌似不可取,最好還是根據(jù)自己的項目需求自己實現(xiàn)一套同步機制。
關(guān)掉Replication:
AActor::SetReplicates( false )
如果實在要用Replication,可以降低更新頻率來提升效率:
AActor::NetUpdateFrequency()
2016-03-29補充:
v4.4開始,shipping編譯出來的版本,會自動禁用Replication,所以如果是對通信性能較高的項目,Replication不要用,只能作為測試工具使用。
Dedicated server connection
https://answers.unrealengine.com/questions/70015/dedicated-server-connection.html
官方解釋:
Performance and Bandwidth Tips
https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Actors/ReplicationPerformance/
When gathering actors for replication, the server will check a few things like relevancy, update frequency, dormancy, etc. You can tweak any of these checks to affect performance. When thinking about making this process as efficient as possible, it's best to prioritize in this order:
-
Turning off replication (
AActor::SetReplicates( false )
)-
When is actor is not replicating, it's not on the list in the first place, so this is the biggest win, to make sure actors that don't need to replicate are marked as such.
-
-
Lower NetUpdateFrequency value
-
The less an actor updates, the less time it takes to update. It's best to make this number as low as possible. This number represents how often per second this actor will replicate to clients.
-
-
Dormancy
-
Relevancy
-
NetClientTicksPerSecond
Don't mark properties to replicate if they aren't absolutely necessary. It's best to try and derive state from existing replicated properties when possible.
Try to take advantage of the quantization functionality that already exists. e.g. FVector_NetQuantize
. These will greatly reduce the size needed to replicate this state over to clients, and if used properly, shouldn't cause any noticeable artifacts.
FName
s are not generally compressed, so when you are using them as parameters to RPCs, keep in mind that they will generally send the string each call. This can be a lot of overhead.
另一篇關(guān)于UE的Replication解釋:
Everything you ever wanted to know about replication (but were afraid to ask)
https://wiki.beyondunreal.com/Everything_you_ever_wanted_to_know_about_replication_(but_were_afraid_to_ask)#Thi
-
分享到:
全部評論:0條