From b1cda4f60243d0eb16e6a7a8a5eecdf2a7fa145b Mon Sep 17 00:00:00 2001 From: Sveske_Juice Date: Wed, 14 Feb 2024 14:45:38 +0100 Subject: [PATCH] Get ropejoints from players and init rope --- .../Prefabs/Networked/NetworkedPlayer.prefab | 143 +++++++++++++++++- .../Scripts/Multiplayer/NetworkedGameSetup.cs | 3 +- Assets/Scripts/Rope/RopeSimulator.cs | 8 +- 3 files changed, 147 insertions(+), 7 deletions(-) diff --git a/Assets/Prefabs/Networked/NetworkedPlayer.prefab b/Assets/Prefabs/Networked/NetworkedPlayer.prefab index 57d1349..170776e 100644 --- a/Assets/Prefabs/Networked/NetworkedPlayer.prefab +++ b/Assets/Prefabs/Networked/NetworkedPlayer.prefab @@ -316,6 +316,8 @@ GameObject: - component: {fileID: 1160419468000791564} - component: {fileID: 1294282455099768770} - component: {fileID: 5998872828059799024} + - component: {fileID: 8582716114041666362} + - component: {fileID: 4721273529951287494} m_Layer: 7 m_Name: NetworkedPlayer m_TagString: Player @@ -355,7 +357,6 @@ MonoBehaviour: m_EditorClassIdentifier: animationHandler: {fileID: 0} moveSpeed: 70 - whipAttack: {fileID: 0} whipSmashSpeed: 2 whipSmashDamageMult: 2 whipMoveSpeed: 25 @@ -490,6 +491,146 @@ MonoBehaviour: objectsToDisable: - {fileID: 1949941092232239315} - {fileID: 5062989152879916107} +--- !u!114 &8582716114041666362 +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: 4aabce12c1341ff488ee4dc806fd80e8, type: 3} + m_Name: + m_EditorClassIdentifier: + anchor: {fileID: 1170758327458850867} + body: {fileID: 1508323898269695585} + locked: 0 + playerInput: {fileID: 1949941092232239315} + playerAnimationHandler: {fileID: 0} + trailRenderer: {fileID: 4721273529951287494} +--- !u!96 &4721273529951287494 +TrailRenderer: + serializedVersion: 3 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3120938410244321186} + m_Enabled: 0 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 0 + m_LightProbeUsage: 0 + m_ReflectionProbeUsage: 0 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 0c2a3048d122d8c48807f52a864f5bee, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Time: 1 + m_PreviewTimeScale: 1 + m_Parameters: + serializedVersion: 3 + widthMultiplier: 1 + widthCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0.33777618 + inSlope: 0.07054916 + outSlope: 0.07054916 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.37911436 + - serializedVersion: 3 + time: 0.5816401 + value: 0 + inSlope: 0.79239726 + outSlope: 0.79239726 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.3712629 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 0.9745941 + value: 0.07111359 + inSlope: 0.4423178 + outSlope: 0.4423178 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.52421325 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + colorGradient: + serializedVersion: 2 + key0: {r: 1, g: 1, b: 1, a: 1} + key1: {r: 1, g: 1, b: 1, a: 1} + key2: {r: 0, g: 0, b: 0, a: 0} + key3: {r: 0, g: 0, b: 0, a: 0} + key4: {r: 0, g: 0, b: 0, a: 0} + key5: {r: 0, g: 0, b: 0, a: 0} + key6: {r: 0, g: 0, b: 0, a: 0} + key7: {r: 0, g: 0, b: 0, a: 0} + ctime0: 0 + ctime1: 65535 + ctime2: 0 + ctime3: 0 + ctime4: 0 + ctime5: 0 + ctime6: 0 + ctime7: 0 + atime0: 0 + atime1: 65535 + atime2: 0 + atime3: 0 + atime4: 0 + atime5: 0 + atime6: 0 + atime7: 0 + m_Mode: 0 + m_ColorSpace: -1 + m_NumColorKeys: 2 + m_NumAlphaKeys: 2 + numCornerVertices: 0 + numCapVertices: 0 + alignment: 0 + textureMode: 0 + textureScale: {x: 1, y: 1} + shadowBias: 0.5 + generateLightingData: 0 + m_MinVertexDistance: 0.1 + m_MaskInteraction: 0 + m_Autodestruct: 0 + m_Emitting: 1 + m_ApplyActiveColorSpace: 1 --- !u!1001 &6225877037457186740 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs b/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs index b93e489..0bad16a 100644 --- a/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs +++ b/Assets/Scripts/Multiplayer/NetworkedGameSetup.cs @@ -64,8 +64,7 @@ public class NetworkedGameSetup : NetworkBehaviour RopeSimulator ropeSim = GetComponentInChildren(); //// Assuming 2 players - //ropeSim.start = new RopeJoint(players[0].transform.position, true); - //ropeSim.start = players[1]; + ropeSim.BuildRope(players[0].GetComponent(), players[1].GetComponent()); } } diff --git a/Assets/Scripts/Rope/RopeSimulator.cs b/Assets/Scripts/Rope/RopeSimulator.cs index dcf9315..bfed76f 100644 --- a/Assets/Scripts/Rope/RopeSimulator.cs +++ b/Assets/Scripts/Rope/RopeSimulator.cs @@ -276,20 +276,20 @@ public class RopeSimulator : MonoBehaviour float startDot = Vector2.Dot((start.position - rope.points[1].position).normalized, start.playerInput.movement); if (startDot > 0.35f) { - start.playerAnimationHandler.animator.SetBool("IsPulling", true); + start.playerAnimationHandler?.animator.SetBool("IsPulling", true); } float endDot = Vector2.Dot((end.position - rope.points[rope.points.Count - 2].position).normalized, end.playerInput.movement); if (endDot > 0.35f) { - end.playerAnimationHandler.animator.SetBool("IsPulling", true); + end.playerAnimationHandler?.animator.SetBool("IsPulling", true); } } else { - start.playerAnimationHandler.animator.SetBool("IsPulling", false); - end.playerAnimationHandler.animator.SetBool("IsPulling", false); + start.playerAnimationHandler?.animator.SetBool("IsPulling", false); + end.playerAnimationHandler?.animator.SetBool("IsPulling", false); } //start.position = prevStartPos;