From e315a7da78037b361ce7e279886bd5e986c33697 Mon Sep 17 00:00:00 2001 From: Brook Bowers Date: Thu, 20 Jan 2022 12:13:18 -0500 Subject: [PATCH] finally fixed hands locally --- .../VelNet/1.0.4/Example/VelNetSyncHand.cs | 35 +++++++++++++------ .../VelNet/1.0.4/Example/testquest.unity | 10 +++++- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/TestVelGameServer/Assets/Samples/VelNet/1.0.4/Example/VelNetSyncHand.cs b/TestVelGameServer/Assets/Samples/VelNet/1.0.4/Example/VelNetSyncHand.cs index 8a771f6..37e97cb 100644 --- a/TestVelGameServer/Assets/Samples/VelNet/1.0.4/Example/VelNetSyncHand.cs +++ b/TestVelGameServer/Assets/Samples/VelNet/1.0.4/Example/VelNetSyncHand.cs @@ -37,6 +37,23 @@ public class VelNetSyncHand : NetworkSerializedObject public Transform Thumb3; */ #endregion + + + private void Start() + { + targets = new Quaternion[toSync.Length]; + InvokeRepeating("NetworkSend", 0, 1 / serializationRateHz); + } + + //TODO: remove when NetworkSerializedObject works + private void NetworkSend() + { + if (IsMine && hand != null && hand.IsDataValid) + { + SendBytes(SendState()); + } + } + protected override void ReceiveState(byte[] message) { using MemoryStream mem = new MemoryStream(message); @@ -59,16 +76,10 @@ public class VelNetSyncHand : NetworkSerializedObject return mem.ToArray(); } - // Start is called before the first frame update - void Start() - { - targets = new Quaternion[toSync.Length]; - } - // Update is called once per frame void Update() { - if (IsMine && hand?.Bones != null && hand?.Bones.Count == toSync.Length) //need to set values from tracked hand to this networkobject + if (IsMine && hand?.Bones != null && hand.IsDataValid) //need to set values from tracked hand to this networkobject { for(int i = 0; i < toSync.Length; i++) { @@ -77,9 +88,13 @@ public class VelNetSyncHand : NetworkSerializedObject return; } - for(int i = 0;i