From 792b5407d2be242c17ace592c597481f58832330 Mon Sep 17 00:00:00 2001 From: BOT Alex <44818698+MagicBOTAlex@users.noreply.github.com> Date: Wed, 28 Feb 2024 14:50:14 +0100 Subject: [PATCH] Rope now connects on join --- Assets/Scripts/Multiplayer/NetworkedGameSetup.cs | 9 ++++----- Assets/Scripts/Rope/RopeSimulator.cs | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs b/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs index 06aeef9..133e011 100644 --- a/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs +++ b/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs @@ -35,11 +35,10 @@ public class NetworkedGameSetup : NetworkBehaviour bool isServer = SteamManager.IsServer || LocalManager.IsServer; GameObject[] players; - players = SpawnPlayers(playerIds); - //if (isServer) - // players = SpawnPlayers(playerIds); - //else - // players = GetPlayers(playerIds); + if (isServer) + players = SpawnPlayers(playerIds); + else + players = GetPlayers(playerIds); //StartCoroutine(LateSetupProcedue(players)); } diff --git a/Assets/Scripts/Rope/RopeSimulator.cs b/Assets/Scripts/Rope/RopeSimulator.cs index 728612e..83ba068 100644 --- a/Assets/Scripts/Rope/RopeSimulator.cs +++ b/Assets/Scripts/Rope/RopeSimulator.cs @@ -74,7 +74,7 @@ public class RopeSimulator : MonoBehaviour public static RopeSimulator instance; - private bool IsInitialized => start == null || end == null; + private bool IsInitialized => !(start == null || end == null); private void Awake() { @@ -88,7 +88,7 @@ public class RopeSimulator : MonoBehaviour } } - private void Start() + private void OnEnable() { // Example of using rope builder //rope = new RopeBuilder() @@ -240,6 +240,13 @@ public class RopeSimulator : MonoBehaviour private void RebuildRopeColliders() { + // Benjamin forgor... to assign + if (ropeCollidersParent == null) + { + var holder = new GameObject("RopeHolder"); + ropeCollidersParent = holder.transform; + } + for (int i = 0; i < ropeCollidersParent.childCount; i++) { Destroy(ropeCollidersParent.GetChild(i)); @@ -263,7 +270,7 @@ public class RopeSimulator : MonoBehaviour private void Update() { - if (IsInitialized) + if (!IsInitialized) return; colliderToSquezeForce.Clear(); @@ -375,6 +382,8 @@ public class RopeSimulator : MonoBehaviour private void OnDrawGizmos() { + return; + if (IsInitialized) return; if (!Application.isPlaying) return;