From 1cb5a4a027f1758736b23aa29347a2d36b9343f7 Mon Sep 17 00:00:00 2001 From: JWS Date: Wed, 2 Feb 2022 19:14:10 -0600 Subject: [PATCH] Removing the network transform child seems to help sync rocks and rockets when connecting multiple clients, the syncvars are all that is needed as I don't update the positions of the child after start. --- Assets/RockField.cs | 14 +++++++++----- Assets/RockSphere.cs | 13 ++++++------- Assets/RockSphere1.prefab | Bin 19680 -> 20096 bytes Assets/RockSphere2.prefab | Bin 19680 -> 20096 bytes Assets/RockSphere3.prefab | Bin 19664 -> 20080 bytes Assets/RocketSphere.prefab | Bin 177296 -> 177152 bytes 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Assets/RockField.cs b/Assets/RockField.cs index 4986548..ab8570b 100644 --- a/Assets/RockField.cs +++ b/Assets/RockField.cs @@ -11,10 +11,9 @@ public class RockField : NetworkBehaviour public GameObject RockSpherePrefab; // Use this for initialization - [Server] - void Start () + public override void OnStartServer() { - //if (!isServer) return; + base.OnStartServer(); for (int i = 0; i < numberOfRocks; i++) { @@ -29,8 +28,13 @@ void Start () } } - // Update is called once per frame - void Update () + public override void OnStartClient() + { + base.OnStartClient(); + } + + // Update is called once per frame + void Update () { } } diff --git a/Assets/RockSphere.cs b/Assets/RockSphere.cs index 74ab8f9..bcd0f01 100644 --- a/Assets/RockSphere.cs +++ b/Assets/RockSphere.cs @@ -13,14 +13,13 @@ public class RockSphere : NetworkBehaviour public GameObject rockSpherePrefab; public int pieces; //public float rotationSpeed; - [SyncVar] bool destroyed = false; - [SyncVar] float radius = 0; - [SyncVar] Vector3 pos = Vector3.zero; - [SyncVar] Quaternion rot = Quaternion.identity; + [SyncVar] public bool destroyed = false; + [SyncVar] public float radius = 0; + [SyncVar] public Vector3 pos = Vector3.zero; + [SyncVar] public Quaternion rot = Quaternion.identity; public static int count = 0; // Use this for initialization -// [Server] public override void OnStartServer() { // call the base function, probably is empty @@ -41,8 +40,8 @@ public override void OnStartServer() // move the child rock to original location and rotation rock = transform.Find("Rock.old").gameObject; - rock.transform.position = pos; - rock.transform.rotation = rot; + rock.transform.localPosition = pos; + rock.transform.localRotation = rot; // apply some rotational torque to the parent gameobject object with the rock attached as a child Rigidbody rb = GetComponent(); diff --git a/Assets/RockSphere1.prefab b/Assets/RockSphere1.prefab index 93e420cc614c3e04e24acac9615a6dccb71aca34..21996a45643f1dab5ca15b7a7f6f55d413cfc201 100644 GIT binary patch delta 678 zcmaDbld)kgqW}Yg%U1>lzXk>d22lnESAmTJU%A9C^Q=tV{n@Ty>z9)o*4_KfZU~e; zz_8g~avAgHgM2cKlm82GD9#58G6Jz05HmP}2nb*ViY{beXjnOUo|<(1Q)Y&S4L}JV zAl3jYPymx4f{}pu-lAVCHNFbN`H^4oxHkh~U15R3c{peRUQ8zhY)&sfj! zl!>8X7f=}JQwAN7JcLqUEqLj^-6Llr|&ehEYQ=4ycu1J3nxcZFSQNxSAS z`KE(91e5?32YD)kIgYGceQu4Q2#lqg5N(=1&%22$&q`C~TX-!N9NvD9Q=M z&nCKUJ!TZlAi#zY`>|wqoXgE}1`VJ(2cQ}t#Sj$y@TX*X1;d5O3mt{EJ^&5%0g5sM zafH48`KpGgMFhllSo-HQ0L?l8qW}Ygb14IZ&jSVq22mh;!bX9wTw<$Cy3RCm`|r8BrdDu;bwY$1PjKbFAD}2R5J%YSpRbzvm|+1M zkPYN>0r3l^np8LSrwl(hCdWC8S%RFw1jKuf|6o*p`QK~>kh2BI2inQ-SVTZm0~DS-_QVvyS@=#>qS$9GlO0Y+(fesuf)Q diff --git a/Assets/RockSphere2.prefab b/Assets/RockSphere2.prefab index 25262efda876025f37d1e10e27c64e1625f6dd18..ef8c4b2c24eaefe66933e24f75c494ebb7cdb601 100644 GIT binary patch delta 692 zcmaDbld)kgqW}Yg%U1>lzXk>d22lnESAmTJU%A9C^Q=tV{n@Ty>z9)o*4_KfZU~e; zz_8g~avAgHgM2cKlm82GD9#58G6Jz05HmP}2nb*ViY{beXjnOUo|<(1Q)Y&S4L}JV zAl3jYPymx4f{}pu-lAVCHNFbN`H^4oxHkh~U15R3c{peRUQ8zhY)&sfj! zl!>8X7f=}JQwAN7JcLqUEqLj^-6Llr|&ehEYQ=4ycu16ku!D$}g~A80(m z#J~UwFIFJF`R-Y2#gc-%4wK(HsEZu{TF?tNpMl|wUyo6zHY9c3AO-<828K02J|__Gvn~iJSrfvL!GRDnd)(~onpMhhVe&$t z2^v5d2cSwI#js;a#+N&~2N*s8jq?HWnL*-iR?2;6o-s%Ojf(*Cxq!GpTVSKZn`aCM zCVzAkS6u)U0s4SJ*W_Yf;%`gy2B5YBKt9kJ4DqE~_E(EE**R?1bqZvj9OW%Ax!+lC QbC2r`Mn;Css_wg40kal`V*mgE delta 338 zcmZpe%lKd>qW}Ygb14IZ&jSVq22mh;!bX9wTw<$Cy3RCm`|r8BrdDu;bwY$1P)kz)%B}WCUU- z>-W0NH-Z>G0L@tg$uNgoXq3FvH6V07FGbD CS6>nU diff --git a/Assets/RockSphere3.prefab b/Assets/RockSphere3.prefab index c8d3237aa6ab2c24a7976082ad157330a3cb5b0b..440f09c5aa326211a5853432efa8e37dcf78908a 100644 GIT binary patch delta 371 zcmcaGlkvkGMgax}m-`G1egzB+45ADSt_&Lme56G$^Q=tV{n@Ty>z9)o*4_KfZU~e; zu(?qBFw5jK#vGjUfm}u)R-3%nRGe|;qkN z-Zm&t3&hjh0p)1}X$A%bFbN_Uf$%94L&Gj08|X9!9TbyvQB2YU^I#_FgLu6AfO5O45C1G!$tugY0*_CU1u7({r6m5Q!BW_Iw3+0C_8_1 zq4Z&v$vX{$CqGy8*&L$uM}D%u(?!OH$%@YQf;B)DtU%mz%&aWz??;IXlM9`NH7~F+ zFmwP#*@2j$Ec~2&R!pD(2Lr`6K%zSH8_>yk{^@UgN{D JImefU5df{RGs*w} diff --git a/Assets/RocketSphere.prefab b/Assets/RocketSphere.prefab index a14168e3284d9df138f8a7cfad306652096b4f9b..a2385a1236f1bf5ad53933a54d11f84c67283c95 100644 GIT binary patch delta 211 zcmbR6lB?kbmjDA(hCTz+76u>?1+oJg1zH6dw+b+=wik_gY3Xiqe&O6D&w_k4?U%Ky z1J!KU{xP0uIrH{%XC@oQ=^SxP!PC=RnPRt}cV$|tz}PUoG>yrc@xt_tX-wik-pMp3 zbH;+{jOk3mng-qs3=KdNc!7BOsuzaRSrOJdJQ)~3R&xWfNl4`GMHlju45r(rGkG)e zZtqNI;$fV=I)lk~`?n0HDEH|}nM^vFJAlh z(o74eX3zEu_Dqji1Q{6^8S;Sq4M5BT#OjkLNQzI~z%e;OUt;0~j>#4J0@LTjG6hd( zb7hKUDK1DX-yZGCv{r#}!gS6wCTqzD?hFhuj0_AcK)qpawUk%goX*Gq6ziEDo5o~r z+u+5(Z~$tw%AI`Chkq2M9K0DA8h~QFKsFh#g?gNzc9Su43?{?rf7UZ)F!D`bo5du)y=DVb1=Dn!O-vly|7>DnVFUmZlwI-w