This commit is contained in:
BOT Alex 2024-02-28 14:50:20 +01:00
commit 4b228771e5
3 changed files with 27 additions and 19 deletions

View File

@ -324,6 +324,7 @@ GameObject:
- component: {fileID: 4721273529951287494}
- component: {fileID: 93986863963319370}
- component: {fileID: -5630779774840087441}
- component: {fileID: 7057145984586355236}
m_Layer: 7
m_Name: NetworkedPlayer
m_TagString: Player
@ -473,7 +474,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier:
GlobalObjectIdHash: 2899378164
GlobalObjectIdHash: 4009941625
InScenePlacedSourceGlobalObjectIdHash: 0
AlwaysReplicateAsRoot: 0
SynchronizeTransform: 1
@ -682,6 +683,18 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b84328426b0c0d34680fca7de411409b, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &7057145984586355236
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3120938410244321186}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 80d7c879794dfda4687da0e400131852, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &6225877037457186740
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -3880,14 +3880,6 @@ PrefabInstance:
propertyPath: m_Name
value: Rope
objectReference: {fileID: 0}
- target: {fileID: 7717684785049474632, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3}
propertyPath: end
value:
objectReference: {fileID: 0}
- target: {fileID: 7717684785049474632, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3}
propertyPath: start
value:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []

View File

@ -54,7 +54,6 @@ public class RopeSimulator : MonoBehaviour
[Header("Rope Colliders")]
[SerializeField] string colliderTag = "Rope";
[SerializeField] LayerMask colliderLayer;
[SerializeField] Transform ropeCollidersParent;
[Header("Rendering")]
@ -86,6 +85,7 @@ public class RopeSimulator : MonoBehaviour
{
Destroy(instance);
}
GameManager.OnPlayersReady += PlayersReady;
}
private void OnEnable()
@ -103,17 +103,18 @@ public class RopeSimulator : MonoBehaviour
// .ConnectPoints(3, 4)
// .Build();
// Build rope if rope joints specified in inspector
if (IsInitialized)
BuildRope(start, end);
}
GameManager.OnPlayersReady += PlayersReady;
private void OnDisable()
{
GameManager.OnPlayersReady -= PlayersReady;
}
public void PlayersReady(GameObject[] players)
{
if (IsInitialized) return;
//if (IsInitialized) return;
Debug.Log(players[0].name);
BuildRope(players[0].GetComponent<RopeJoint>(), players[1].GetComponent<RopeJoint>());
}
@ -123,11 +124,13 @@ public class RopeSimulator : MonoBehaviour
Assert.IsNotNull(end);
// Sanity check if rope simulator was initialized before - we are re-building the rope
if (IsInitialized)
if (this.start != null)
{
this.start.playerInput.ropeLengthExtend -= ExtendRope;
this.start.playerInput.ropeLengthShrinken -= ShrinkenRope;
}
if (this.end != null)
{
this.end.playerInput.ropeLengthExtend -= ExtendRope;
this.end.playerInput.ropeLengthShrinken -= ShrinkenRope;
}
@ -258,7 +261,7 @@ public class RopeSimulator : MonoBehaviour
ropeCollider.tag = colliderTag;
ropeCollider.transform.parent = ropeCollidersParent;
ropeCollider.transform.position = point.position;
ropeCollider.layer = colliderLayer;
ropeCollider.layer = LayerMask.NameToLayer("Rope");
var colliderComponent = ropeCollider.AddComponent<CircleCollider2D>();
colliderComponent.radius = ropeRadius;