diff --git a/Assets/Resources/Player2.prefab b/Assets/Resources/Player2.prefab index f98123a..e581c85 100644 --- a/Assets/Resources/Player2.prefab +++ b/Assets/Resources/Player2.prefab @@ -187,6 +187,7 @@ GameObject: - component: {fileID: 1508323898269695585} - component: {fileID: 5467488512035376674} - component: {fileID: 3878447480781341932} + - component: {fileID: 7071433868121438663} m_Layer: 7 m_Name: Player2 m_TagString: Player @@ -223,10 +224,14 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 3dbdb849a2f5df14d9e109a7776c5ac0, type: 3} m_Name: m_EditorClassIdentifier: - moveSpeed: 5 + player: 1 + moveSpeed: 65 stepCooldown: 0.2 stepVibrationTime: 0.05 rumble: {fileID: 0} + whipAttack: {fileID: 7071433868121438663} + whipMoveSpeed: 25 + maxWhipMoveSpeed: 30 --- !u!114 &3086165646112058191 MonoBehaviour: m_ObjectHideFlags: 0 @@ -261,7 +266,7 @@ Rigidbody2D: m_UseFullKinematicContacts: 0 m_UseAutoMass: 0 m_Mass: 1 - m_LinearDrag: 0 + m_LinearDrag: 10 m_AngularDrag: 0.05 m_GravityScale: 0 m_Material: {fileID: 6200000, guid: 7c680ffb793a1f2478e6682c957e4868, type: 2} @@ -302,3 +307,19 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9c2ddf673a65d3d49bc9470e1a4572e4, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &7071433868121438663 +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: b69b92d72c7244443854899c4b700d9c, type: 3} + m_Name: + m_EditorClassIdentifier: + otherPlayerAttack: {fileID: 0} + playerMovement: {fileID: 651446758998956252} + joint: {fileID: 5467488512035376674} + initialDrag: 0 diff --git a/Assets/Scenes/MovementTest.unity b/Assets/Scenes/MovementTest.unity index 8773737..0c67276 100644 --- a/Assets/Scenes/MovementTest.unity +++ b/Assets/Scenes/MovementTest.unity @@ -362,105 +362,6 @@ MonoBehaviour: m_Area: 1 m_IgnoreFromBuild: 0 m_AffectedAgents: ffffffff ---- !u!1 &107616016 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 107616020} - - component: {fileID: 107616021} - - component: {fileID: 107616018} - - component: {fileID: 107616017} - m_Layer: 0 - m_Name: Player 2 - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!50 &107616017 -Rigidbody2D: - serializedVersion: 4 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 107616016} - m_BodyType: 0 - m_Simulated: 1 - m_UseFullKinematicContacts: 0 - m_UseAutoMass: 0 - m_Mass: 1 - m_LinearDrag: 0 - m_AngularDrag: 0.05 - m_GravityScale: 0 - m_Material: {fileID: 0} - m_IncludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ExcludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_Interpolate: 0 - m_SleepingMode: 1 - m_CollisionDetection: 1 - m_Constraints: 0 ---- !u!114 &107616018 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 107616016} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3} - m_Name: - m_EditorClassIdentifier: - maxHealth: 100 - OnHealthZero: - m_PersistentCalls: - m_Calls: [] - OnHealthChange: - m_PersistentCalls: - m_Calls: [] - minThreshold: 1 - squezeDamageScalor: 1 ---- !u!4 &107616020 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 107616016} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 3.51, y: 1.14, z: -0.09089095} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 1682789264} - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &107616021 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 107616016} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e891644cda7544948af35b0d2f2c3be2, type: 3} - m_Name: - m_EditorClassIdentifier: - moveSpeed: 5 - stepCooldown: 0.2 - stepVibrationTime: 0.05 - rumble: {fileID: 1744797149} --- !u!1 &220016280 GameObject: m_ObjectHideFlags: 0 @@ -480,7 +381,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!114 &220016281 MonoBehaviour: m_ObjectHideFlags: 0 @@ -493,7 +394,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6a3ffc4a3af9e0243ac9ee0c995bb82f, type: 3} m_Name: m_EditorClassIdentifier: - target: {fileID: 2026065165} + targets: + - {fileID: 2026065165} + - {fileID: 780144035302788033} + ropeDistCheck: 1 + ropeCheckMask: + serializedVersion: 2 + m_Bits: 64 --- !u!195 &220016282 NavMeshAgent: m_ObjectHideFlags: 0 @@ -1781,90 +1688,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1666646756} m_CullTransparentMesh: 1 ---- !u!1 &1682789263 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1682789264} - - component: {fileID: 1682789265} - m_Layer: 0 - m_Name: Renderer - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1682789264 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1682789263} - serializedVersion: 2 - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.7082175, y: 0.44170734, z: 0.09089095} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 107616020} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &1682789265 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1682789263} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 0 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, 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: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: -2413806693520163455, guid: a86470a33a6bf42c4b3595704624658b, type: 3} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 1, y: 1} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 --- !u!1 &1744797149 GameObject: m_ObjectHideFlags: 0 @@ -1914,6 +1737,94 @@ Transform: m_CorrespondingSourceObject: {fileID: 320690117028550720, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} m_PrefabInstance: {fileID: 6593404997020511677} m_PrefabAsset: {fileID: 0} +--- !u!114 &2026065166 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1749848915408613053, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} + m_PrefabInstance: {fileID: 6593404997020511677} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b69b92d72c7244443854899c4b700d9c, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &780144035302788026 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + propertyPath: m_LocalPosition.x + value: -15.740316 + objectReference: {fileID: 0} + - target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + propertyPath: m_LocalPosition.y + value: -3.0342276 + objectReference: {fileID: 0} + - target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + propertyPath: m_LocalPosition.z + value: -0.09089095 + objectReference: {fileID: 0} + - target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + propertyPath: m_Name + value: Player2 + objectReference: {fileID: 0} + - target: {fileID: 7071433868121438663, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + propertyPath: otherPlayerAttack + value: + objectReference: {fileID: 2026065166} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} +--- !u!114 &780144035302788027 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 7071433868121438663, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + m_PrefabInstance: {fileID: 780144035302788026} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b69b92d72c7244443854899c4b700d9c, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &780144035302788033 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + m_PrefabInstance: {fileID: 780144035302788026} + m_PrefabAsset: {fileID: 0} --- !u!1001 &6593404997020511677 PrefabInstance: m_ObjectHideFlags: 0 @@ -1966,14 +1877,14 @@ PrefabInstance: propertyPath: rumble value: objectReference: {fileID: 1744797149} + - target: {fileID: 1749848915408613053, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} + propertyPath: otherPlayerAttack + value: + objectReference: {fileID: 780144035302788027} - target: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} propertyPath: m_Name value: Player objectReference: {fileID: 0} - - target: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} - propertyPath: m_IsActive - value: 0 - objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] @@ -1985,7 +1896,6 @@ SceneRoots: m_Roots: - {fileID: 63829549} - {fileID: 6593404997020511677} - - {fileID: 107616020} - {fileID: 646449338} - {fileID: 1420709241} - {fileID: 1602984459} @@ -1993,3 +1903,4 @@ SceneRoots: - {fileID: 1365819705} - {fileID: 220016284} - {fileID: 1180110923} + - {fileID: 780144035302788026} diff --git a/Assets/Scripts/Controller/RumbleManager.cs b/Assets/Scripts/Controller/RumbleManager.cs index a04c842..434ae9d 100644 --- a/Assets/Scripts/Controller/RumbleManager.cs +++ b/Assets/Scripts/Controller/RumbleManager.cs @@ -11,7 +11,7 @@ public class RumbleManager : MonoBehaviour private Coroutine stopRumbleAfterTimeCorutine; - public void RumblePulse1(float lowFrequency, float highFrequency, float duration) + public void RumblePulse(float lowFrequency, float highFrequency, float duration, int player) { pad1 = Gamepad.all[0]; if (pad1 != null) @@ -21,16 +21,6 @@ public class RumbleManager : MonoBehaviour stopRumbleAfterTimeCorutine = StartCoroutine(stopRumble(duration, pad1)); } } - public void RumblePulse2(float lowFrequency, float highFrequency, float duration) - { - pad2 = Gamepad.all[1]; - if (pad2 != null) - { - pad2.SetMotorSpeeds(lowFrequency, highFrequency); - - stopRumbleAfterTimeCorutine = StartCoroutine(stopRumble(duration, pad2)); - } - } private IEnumerator stopRumble(float duration, Gamepad pad) { diff --git a/Assets/Scripts/Player/PlayerMovement.cs b/Assets/Scripts/Player/PlayerMovement.cs index 4758c3d..090576c 100644 --- a/Assets/Scripts/Player/PlayerMovement.cs +++ b/Assets/Scripts/Player/PlayerMovement.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; +using System.Linq; public class PlayerMovement : MonoBehaviour { @@ -33,7 +34,7 @@ public class PlayerMovement : MonoBehaviour { rb = GetComponent(); - playerController = Gamepad.all[player]; + playerController = Gamepad.all.ElementAtOrDefault(player); StartCoroutine(ToggleWithDelay()); } @@ -81,12 +82,12 @@ public class PlayerMovement : MonoBehaviour { if (right) { - rumble.GetComponent().RumblePulse1(0.0f, 0.004f, stepVibrationTime); + rumble.GetComponent().RumblePulse(0.0f, 0.004f, stepVibrationTime, player); right = false; } else if (!right) { - rumble.GetComponent().RumblePulse1(0.004f, 0.0f, stepVibrationTime); + rumble.GetComponent().RumblePulse(0.004f, 0.0f, stepVibrationTime, player); right = true; } vibrate = false; diff --git a/Assets/Scripts/Player/RopeWhipAttack.cs b/Assets/Scripts/Player/RopeWhipAttack.cs index f8c8f09..1c89a23 100644 --- a/Assets/Scripts/Player/RopeWhipAttack.cs +++ b/Assets/Scripts/Player/RopeWhipAttack.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; +using System.Linq; public class RopeWhipAttack : MonoBehaviour { @@ -9,6 +10,7 @@ public class RopeWhipAttack : MonoBehaviour public PlayerMovement playerMovement; public RopeJoint joint; + Gamepad controller; public bool IsWhippingOtherPlayer => joint.locked; public bool IsBeingWhipped => otherPlayerAttack.joint.locked; @@ -17,14 +19,16 @@ public class RopeWhipAttack : MonoBehaviour private void Awake() { initialDrag = joint.body.drag; + controller = Gamepad.all.ElementAtOrDefault(playerMovement.player); } private void Update() { // Other player is whip attacking if (otherPlayerAttack.joint.locked) return; - - if (Gamepad.all[playerMovement.player].rightShoulder.IsPressed()) + if (controller == null) + return; + if (controller.rightShoulder.IsPressed()) { joint.locked = true; otherPlayerAttack.joint.body.drag = 0f;