Rope test
This commit is contained in:
parent
8a4a50bd67
commit
e98dd018bb
|
@ -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
|
||||
|
@ -658,7 +659,7 @@ MonoBehaviour:
|
|||
SyncRotAngleX: 0
|
||||
SyncRotAngleY: 0
|
||||
SyncRotAngleZ: 0
|
||||
SyncScaleX: 0
|
||||
SyncScaleX: 1
|
||||
SyncScaleY: 0
|
||||
SyncScaleZ: 0
|
||||
PositionThreshold: 0.001
|
||||
|
@ -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
|
||||
|
|
|
@ -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: []
|
||||
|
|
|
@ -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 Start()
|
||||
|
@ -102,18 +102,19 @@ public class RopeSimulator : MonoBehaviour
|
|||
// .ConnectPoints(2, 3)
|
||||
// .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;
|
||||
}
|
||||
|
@ -251,7 +254,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;
|
||||
|
|
Loading…
Reference in New Issue