rope rebuild giving errors
This commit is contained in:
parent
5fb3197aba
commit
32f5f27201
|
@ -3734,20 +3734,12 @@ PrefabInstance:
|
|||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects:
|
||||
- targetCorrespondingSourceObject: {fileID: 3032075919872812610, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 4910321061857220296}
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 809911508645467208, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1683288374126251323}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3}
|
||||
--- !u!4 &1683288374126251322 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 3032075919872812610, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3}
|
||||
m_PrefabInstance: {fileID: 1683288374126251321}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &1683288374126251323
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -3891,7 +3883,7 @@ PrefabInstance:
|
|||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 1683288374126251322}
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 144529238244638330, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
|
@ -3950,11 +3942,6 @@ PrefabInstance:
|
|||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3}
|
||||
--- !u!4 &4910321061857220296 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 144529238244638330, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3}
|
||||
m_PrefabInstance: {fileID: 4910321061857220295}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &5796191506433166633
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -4822,6 +4809,7 @@ PrefabInstance:
|
|||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Roots:
|
||||
- {fileID: 4910321061857220295}
|
||||
- {fileID: 1683288374126251321}
|
||||
- {fileID: 1536317696}
|
||||
- {fileID: 4158834148864819266}
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using static UnityEditor.Experimental.GraphView.GraphView;
|
||||
|
||||
public class NetworkedGameSetup : NetworkBehaviour
|
||||
{
|
||||
|
@ -34,6 +35,13 @@ public class NetworkedGameSetup : NetworkBehaviour
|
|||
else
|
||||
players = GetPlayers(playerIds);
|
||||
|
||||
StartCoroutine(LateSetupProcedue(players));
|
||||
}
|
||||
|
||||
private IEnumerator LateSetupProcedue(GameObject[] players)
|
||||
{
|
||||
yield return new WaitForSecondsRealtime(0.01f);
|
||||
|
||||
InitRope(players);
|
||||
|
||||
InitUpgrader(players);
|
||||
|
@ -43,13 +51,7 @@ public class NetworkedGameSetup : NetworkBehaviour
|
|||
|
||||
private GameObject[] GetPlayers(List<ulong> playerIds)
|
||||
{
|
||||
GameObject[] players = new GameObject[playerIds.Count];
|
||||
|
||||
for (int i = 0; i < playerIds.Count; i++)
|
||||
{
|
||||
ulong playerId = playerIds[i];
|
||||
players[i] = NetworkManager.SpawnManager.SpawnedObjects[playerId].gameObject;
|
||||
}
|
||||
GameObject[] players = NetworkManager.SpawnManager.SpawnedObjects.Select(x=>x.Value.gameObject).ToArray();
|
||||
|
||||
return players;
|
||||
}
|
||||
|
@ -70,10 +72,8 @@ public class NetworkedGameSetup : NetworkBehaviour
|
|||
|
||||
private void InitRope(GameObject[] players)
|
||||
{
|
||||
RopeSimulator ropeSim = GetComponentInChildren<RopeSimulator>();
|
||||
|
||||
// Assuming 2 players
|
||||
ropeSim.BuildRope(players[0].GetComponent<RopeJoint>(), players[1].GetComponent<RopeJoint>());
|
||||
RopeSimulator.instance.BuildRope(players[0].GetComponent<RopeJoint>(), players[1].GetComponent<RopeJoint>());
|
||||
}
|
||||
|
||||
private void InitUpgrader(GameObject[] players)
|
||||
|
|
|
@ -70,6 +70,20 @@ public class RopeSimulator : MonoBehaviour
|
|||
|
||||
Dictionary<Collider2D, float> colliderToSquezeForce = new();
|
||||
|
||||
public static RopeSimulator instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(instance);
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Example of using rope builder
|
||||
|
@ -178,6 +192,8 @@ public class RopeSimulator : MonoBehaviour
|
|||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (start == null || end == null) return;
|
||||
|
||||
start.playerInput.ropeLengthShrinken -= ShrinkenRope;
|
||||
end.playerInput.ropeLengthShrinken -= ShrinkenRope;
|
||||
|
||||
|
|
Loading…
Reference in New Issue