From 74adab7b52063179596e735253106a4f6c119de9 Mon Sep 17 00:00:00 2001 From: BOT Alex <44818698+MagicBOTAlex@users.noreply.github.com> Date: Sun, 4 Feb 2024 06:12:13 +0100 Subject: [PATCH] Added vibration manager --- Assets/Prefabs/CameraRig.prefab | 65 +++- Assets/Prefabs/Managers.prefab | 15 +- Assets/Prefabs/Rope.prefab | 111 ++++++ Assets/Resources/Player1.prefab | 50 ++- Assets/Resources/Player2.prefab | 50 ++- Assets/Scenes/GameScene.unity | 331 +----------------- Assets/Scripts/Controller/RumbleManager.cs | 35 -- Assets/Scripts/Rumbling/PlayerRumbling.cs | 84 ----- Assets/Scripts/Rumbling/RopeRumbling.cs | 48 +++ ...rRumbling.cs.meta => RopeRumbling.cs.meta} | 0 Assets/Scripts/Rumbling/RumbleManager.cs | 139 ++++++++ .../RumbleManager.cs.meta | 2 +- 12 files changed, 483 insertions(+), 447 deletions(-) delete mode 100644 Assets/Scripts/Controller/RumbleManager.cs delete mode 100644 Assets/Scripts/Rumbling/PlayerRumbling.cs create mode 100644 Assets/Scripts/Rumbling/RopeRumbling.cs rename Assets/Scripts/Rumbling/{PlayerRumbling.cs.meta => RopeRumbling.cs.meta} (100%) create mode 100644 Assets/Scripts/Rumbling/RumbleManager.cs rename Assets/Scripts/{Controller => Rumbling}/RumbleManager.cs.meta (83%) diff --git a/Assets/Prefabs/CameraRig.prefab b/Assets/Prefabs/CameraRig.prefab index 0798d41..1a48ed3 100644 --- a/Assets/Prefabs/CameraRig.prefab +++ b/Assets/Prefabs/CameraRig.prefab @@ -14,6 +14,7 @@ GameObject: - component: {fileID: 5510899577631708383} - component: {fileID: 4289092251764458493} - component: {fileID: 3603265075407754381} + - component: {fileID: 7140252695900592518} m_Layer: 0 m_Name: MainCamera m_TagString: MainCamera @@ -118,7 +119,7 @@ MonoBehaviour: m_Bits: 1 m_VolumeTrigger: {fileID: 0} m_VolumeFrameworkUpdateModeOption: 2 - m_RenderPostProcessing: 0 + m_RenderPostProcessing: 1 m_Antialiasing: 0 m_AntialiasingQuality: 2 m_StopNaN: 0 @@ -187,7 +188,7 @@ MonoBehaviour: m_EditorClassIdentifier: Wave: 0 difficulty: 1 - difficultyIncreasePerWave: 1 + difficultyIncreasePerWave: 3 difficultyMultiplyDecreasePerWave: 0.05 WaveTime: 20 enemyDifficulties: [] @@ -198,6 +199,66 @@ MonoBehaviour: - {fileID: 0} initialSpawnDelay: 5 enemyList: [] +--- !u!114 &7140252695900592518 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2173372557174057003} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 948f4100a11a5c24981795d21301da5c, type: 3} + m_Name: + m_EditorClassIdentifier: + volumeTrigger: {fileID: 8946450710138871461} + volumeLayer: + serializedVersion: 2 + m_Bits: 257 + stopNaNPropagation: 1 + finalBlitToCameraTarget: 0 + antialiasingMode: 0 + temporalAntialiasing: + jitterSpread: 0.75 + sharpness: 0.25 + stationaryBlending: 0.95 + motionBlending: 0.85 + subpixelMorphologicalAntialiasing: + quality: 2 + fastApproximateAntialiasing: + fastMode: 0 + keepAlpha: 0 + fog: + enabled: 1 + excludeSkybox: 1 + debugLayer: + lightMeter: + width: 512 + height: 256 + showCurves: 1 + histogram: + width: 512 + height: 256 + channel: 3 + waveform: + exposure: 0.12 + height: 256 + vectorscope: + size: 256 + exposure: 0.12 + overlaySettings: + linearDepth: 0 + motionColorIntensity: 4 + motionGridSize: 64 + colorBlindnessType: 0 + colorBlindnessStrength: 1 + m_Resources: {fileID: 11400000, guid: d82512f9c8e5d4a4d938b575d47f88d4, type: 2} + m_ShowToolkit: 0 + m_ShowCustomSorter: 0 + breakBeforeColorGrading: 0 + m_BeforeTransparentBundles: [] + m_BeforeStackBundles: [] + m_AfterStackBundles: [] --- !u!1 &2607936989766580656 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Managers.prefab b/Assets/Prefabs/Managers.prefab index bc71297..207ecc7 100644 --- a/Assets/Prefabs/Managers.prefab +++ b/Assets/Prefabs/Managers.prefab @@ -10,6 +10,7 @@ GameObject: m_Component: - component: {fileID: 3032075919872812610} - component: {fileID: 6372697238776542044} + - component: {fileID: 1114532058491094574} m_Layer: 0 m_Name: Managers m_TagString: Untagged @@ -44,4 +45,16 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d07fc52b48ce953488ecef079872f5b7, type: 3} m_Name: m_EditorClassIdentifier: - audioLibrary: {fileID: 0} + audioLibrary: {fileID: 11400000, guid: 90a0ccefc407688499165286d0638124, type: 2} +--- !u!114 &1114532058491094574 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 809911508645467208} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6cf314e58a8539a448e6ddeb3ad48149, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Prefabs/Rope.prefab b/Assets/Prefabs/Rope.prefab index eab5300..49ac832 100644 --- a/Assets/Prefabs/Rope.prefab +++ b/Assets/Prefabs/Rope.prefab @@ -11,6 +11,8 @@ GameObject: - component: {fileID: 144529238244638330} - component: {fileID: 7717684785049474632} - component: {fileID: 901761791259710742} + - component: {fileID: 4976294692568481572} + - component: {fileID: 2066655509941542230} m_Layer: 0 m_Name: Rope m_TagString: Untagged @@ -169,3 +171,112 @@ LineRenderer: m_UseWorldSpace: 1 m_Loop: 0 m_ApplyActiveColorSpace: 1 +--- !u!114 &4976294692568481572 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5991265243222894942} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8766ad5393174fa488ef4a58b62181b4, type: 3} + m_Name: + m_EditorClassIdentifier: + PlayTime: 1 +--- !u!82 &2066655509941542230 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5991265243222894942} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 8300000, guid: fd92966d4cde3244d9a711094cb947f6, type: 3} + m_PlayOnAwake: 0 + m_Volume: 0.107 + m_Pitch: 1 + Loop: 1 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 diff --git a/Assets/Resources/Player1.prefab b/Assets/Resources/Player1.prefab index 7b17070..717aa82 100644 --- a/Assets/Resources/Player1.prefab +++ b/Assets/Resources/Player1.prefab @@ -274,6 +274,9 @@ GameObject: - component: {fileID: 1749848915408613053} - component: {fileID: 1949941092232239315} - component: {fileID: 1449424410418603396} + - component: {fileID: 8584374946327201457} + - component: {fileID: 2455289449300252362} + - component: {fileID: 3389629528887116870} m_Layer: 7 m_Name: Player1 m_TagString: Player @@ -313,9 +316,6 @@ MonoBehaviour: m_EditorClassIdentifier: animationHandler: {fileID: 3878447480781341932} moveSpeed: 70 - stepCooldown: 0.2 - stepVibrationTime: 0.05 - rumble: {fileID: 0} whipAttack: {fileID: 1749848915408613053} whipMoveSpeed: 25 maxWhipMoveSpeed: 30 @@ -331,7 +331,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3} m_Name: m_EditorClassIdentifier: + onlyCallZeroHealthOnce: 1 maxHealth: 100 + damageTickDelay: 0.25 OnHealthZero: m_PersistentCalls: m_Calls: [] @@ -441,6 +443,48 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6b097a132c072b72fbc7808ebf263e52, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &8584374946327201457 +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: c66441ada081b6c4c841000e83cc2b7a, type: 3} + m_Name: + m_EditorClassIdentifier: + invert: 0 +--- !u!114 &2455289449300252362 +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: d4d58ce9310f45c42af5d8003f1a832c, type: 3} + m_Name: + m_EditorClassIdentifier: + StepInterval: 0.8 + Volume: 0.25 +--- !u!114 &3389629528887116870 +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: 20d294d88e5bc8a42afb1f72751fb61f, type: 3} + m_Name: + m_EditorClassIdentifier: + RopeRubleTolerance: 0.25 + MaxVibration: 0.8 + rope: {fileID: 0} --- !u!1001 &6225877037457186740 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Player2.prefab b/Assets/Resources/Player2.prefab index 889c005..d1b7880 100644 --- a/Assets/Resources/Player2.prefab +++ b/Assets/Resources/Player2.prefab @@ -190,6 +190,9 @@ GameObject: - component: {fileID: 7071433868121438663} - component: {fileID: 1949941092232239315} - component: {fileID: 7729933180365677331} + - component: {fileID: 507903157909478597} + - component: {fileID: 3245702757494549198} + - component: {fileID: 5108819328747686001} m_Layer: 7 m_Name: Player2 m_TagString: Player @@ -229,9 +232,6 @@ MonoBehaviour: m_EditorClassIdentifier: animationHandler: {fileID: 3878447480781341932} moveSpeed: 65 - stepCooldown: 0.2 - stepVibrationTime: 0.05 - rumble: {fileID: 0} whipAttack: {fileID: 7071433868121438663} whipMoveSpeed: 25 maxWhipMoveSpeed: 30 @@ -247,7 +247,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3} m_Name: m_EditorClassIdentifier: + onlyCallZeroHealthOnce: 1 maxHealth: 100 + damageTickDelay: 0.25 OnHealthZero: m_PersistentCalls: m_Calls: [] @@ -357,6 +359,48 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6b097a132c072b72fbc7808ebf263e52, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &507903157909478597 +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: c66441ada081b6c4c841000e83cc2b7a, type: 3} + m_Name: + m_EditorClassIdentifier: + invert: 0 +--- !u!114 &3245702757494549198 +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: d4d58ce9310f45c42af5d8003f1a832c, type: 3} + m_Name: + m_EditorClassIdentifier: + StepInterval: 0.8 + Volume: 0.25 +--- !u!114 &5108819328747686001 +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: 20d294d88e5bc8a42afb1f72751fb61f, type: 3} + m_Name: + m_EditorClassIdentifier: + RopeRubleTolerance: 0.25 + MaxVibration: 0.8 + rope: {fileID: 0} --- !u!1 &7787472247078384126 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/GameScene.unity b/Assets/Scenes/GameScene.unity index ea3631c..f1070b4 100644 --- a/Assets/Scenes/GameScene.unity +++ b/Assets/Scenes/GameScene.unity @@ -1161,14 +1161,14 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 651446758998956252, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} - propertyPath: rumble - value: - objectReference: {fileID: 147729521} - target: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} propertyPath: m_Name value: Player2 objectReference: {fileID: 0} + - target: {fileID: 5108819328747686001, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} + propertyPath: rope + value: + objectReference: {fileID: 1920006248} - target: {fileID: 7071433868121438663, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} propertyPath: otherPlayerAttack value: @@ -1176,16 +1176,7 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: - - targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} - insertIndex: -1 - addedObject: {fileID: 1579580571} - - targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} - insertIndex: -1 - addedObject: {fileID: 1579580572} - - targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} - insertIndex: -1 - addedObject: {fileID: 1579580579} + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} --- !u!114 &869964774 stripped MonoBehaviour: @@ -1473,10 +1464,6 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 651446758998956252, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} - propertyPath: rumble - value: - objectReference: {fileID: 147729521} - target: {fileID: 1749848915408613053, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} propertyPath: otherPlayerAttack value: @@ -1485,19 +1472,14 @@ PrefabInstance: propertyPath: m_Name value: Player1 objectReference: {fileID: 0} + - target: {fileID: 3389629528887116870, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} + propertyPath: rope + value: + objectReference: {fileID: 1920006248} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: - - targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} - insertIndex: -1 - addedObject: {fileID: 1254139636} - - targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} - insertIndex: -1 - addedObject: {fileID: 1254139637} - - targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} - insertIndex: -1 - addedObject: {fileID: 1254139644} + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} --- !u!114 &1232208433 stripped MonoBehaviour: @@ -1531,47 +1513,6 @@ GameObject: m_CorrespondingSourceObject: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} m_PrefabInstance: {fileID: 1232208432} m_PrefabAsset: {fileID: 0} ---- !u!114 &1254139636 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1254139629} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c66441ada081b6c4c841000e83cc2b7a, type: 3} - m_Name: - m_EditorClassIdentifier: - invert: 0 ---- !u!114 &1254139637 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1254139629} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d4d58ce9310f45c42af5d8003f1a832c, type: 3} - m_Name: - m_EditorClassIdentifier: - StepInterval: 0.8 - Volume: 0.25 ---- !u!114 &1254139644 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1254139629} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 20d294d88e5bc8a42afb1f72751fb61f, type: 3} - m_Name: - m_EditorClassIdentifier: - RopeRubleTolerance: 0.5 - rope: {fileID: 1920006248} --- !u!1 &1377274208 GameObject: m_ObjectHideFlags: 0 @@ -3219,47 +3160,6 @@ GameObject: m_CorrespondingSourceObject: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} m_PrefabInstance: {fileID: 869964773} m_PrefabAsset: {fileID: 0} ---- !u!114 &1579580571 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1579580564} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c66441ada081b6c4c841000e83cc2b7a, type: 3} - m_Name: - m_EditorClassIdentifier: - invert: 0 ---- !u!114 &1579580572 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1579580564} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d4d58ce9310f45c42af5d8003f1a832c, type: 3} - m_Name: - m_EditorClassIdentifier: - StepInterval: 0.8 - Volume: 0.25 ---- !u!114 &1579580579 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1579580564} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 20d294d88e5bc8a42afb1f72751fb61f, type: 3} - m_Name: - m_EditorClassIdentifier: - RopeRubleTolerance: 0.5 - rope: {fileID: 1920006248} --- !u!1 &1600052931 GameObject: m_ObjectHideFlags: 0 @@ -3591,7 +3491,7 @@ MonoBehaviour: m_CorrespondingSourceObject: {fileID: 7717684785049474632, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3} m_PrefabInstance: {fileID: 4910321061857220295} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4910321061857220296} + m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 27ac133d9e10e544ba603e07122e3359, type: 3} @@ -3835,10 +3735,6 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 6372697238776542044, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3} - propertyPath: audioLibrary - value: - objectReference: {fileID: 11400000, guid: 90a0ccefc407688499165286d0638124, type: 2} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] @@ -3907,128 +3803,8 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: - - targetCorrespondingSourceObject: {fileID: 5991265243222894942, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3} - insertIndex: -1 - addedObject: {fileID: 4910321061857220297} - - targetCorrespondingSourceObject: {fileID: 5991265243222894942, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3} - insertIndex: -1 - addedObject: {fileID: 4910321061857220300} + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3} ---- !u!1 &4910321061857220296 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 5991265243222894942, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3} - m_PrefabInstance: {fileID: 4910321061857220295} - m_PrefabAsset: {fileID: 0} ---- !u!114 &4910321061857220297 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4910321061857220296} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8766ad5393174fa488ef4a58b62181b4, type: 3} - m_Name: - m_EditorClassIdentifier: - PlayTime: 1 ---- !u!82 &4910321061857220300 -AudioSource: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4910321061857220296} - m_Enabled: 1 - serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 8300000, guid: fd92966d4cde3244d9a711094cb947f6, type: 3} - m_PlayOnAwake: 0 - m_Volume: 0.107 - m_Pitch: 1 - Loop: 1 - Mute: 0 - Spatialize: 0 - SpatializePostEffects: 0 - Priority: 128 - DopplerLevel: 1 - MinDistance: 1 - MaxDistance: 500 - Pan2D: 0 - rolloffMode: 0 - BypassEffects: 0 - BypassListenerEffects: 0 - BypassReverbZones: 0 - rolloffCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - panLevelCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - spreadCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - reverbZoneMixCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 --- !u!1001 &5796191506433166633 PrefabInstance: m_ObjectHideFlags: 0 @@ -4053,14 +3829,6 @@ PrefabInstance: propertyPath: players.Array.data[1] value: objectReference: {fileID: 1579580564} - - target: {fileID: 3603265075407754381, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} - propertyPath: difficultyIncreasePerWave - value: 3 - objectReference: {fileID: 0} - - target: {fileID: 5510899577631708383, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} - propertyPath: m_RenderPostProcessing - value: 1 - objectReference: {fileID: 0} - target: {fileID: 5959206239141280122, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} propertyPath: m_LocalPosition.x value: 0 @@ -4108,81 +3876,8 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: - - targetCorrespondingSourceObject: {fileID: 2173372557174057003, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} - insertIndex: -1 - addedObject: {fileID: 5796191506433166636} + m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} ---- !u!4 &5796191506433166634 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 8946450710138871461, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} - m_PrefabInstance: {fileID: 5796191506433166633} - m_PrefabAsset: {fileID: 0} ---- !u!1 &5796191506433166635 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 2173372557174057003, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} - m_PrefabInstance: {fileID: 5796191506433166633} - m_PrefabAsset: {fileID: 0} ---- !u!114 &5796191506433166636 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5796191506433166635} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 948f4100a11a5c24981795d21301da5c, type: 3} - m_Name: - m_EditorClassIdentifier: - volumeTrigger: {fileID: 5796191506433166634} - volumeLayer: - serializedVersion: 2 - m_Bits: 257 - stopNaNPropagation: 1 - finalBlitToCameraTarget: 0 - antialiasingMode: 0 - temporalAntialiasing: - jitterSpread: 0.75 - sharpness: 0.25 - stationaryBlending: 0.95 - motionBlending: 0.85 - subpixelMorphologicalAntialiasing: - quality: 2 - fastApproximateAntialiasing: - fastMode: 0 - keepAlpha: 0 - fog: - enabled: 1 - excludeSkybox: 1 - debugLayer: - lightMeter: - width: 512 - height: 256 - showCurves: 1 - histogram: - width: 512 - height: 256 - channel: 3 - waveform: - exposure: 0.12 - height: 256 - vectorscope: - size: 256 - exposure: 0.12 - overlaySettings: - linearDepth: 0 - motionColorIntensity: 4 - motionGridSize: 64 - colorBlindnessType: 0 - colorBlindnessStrength: 1 - m_Resources: {fileID: 11400000, guid: d82512f9c8e5d4a4d938b575d47f88d4, type: 2} - m_ShowToolkit: 0 - m_ShowCustomSorter: 0 - breakBeforeColorGrading: 0 - m_BeforeTransparentBundles: [] - m_BeforeStackBundles: [] - m_AfterStackBundles: [] --- !u!1001 &7693964683212020007 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Controller/RumbleManager.cs b/Assets/Scripts/Controller/RumbleManager.cs deleted file mode 100644 index f801e27..0000000 --- a/Assets/Scripts/Controller/RumbleManager.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.InputSystem; - -public class RumbleManager : MonoBehaviour -{ - private Gamepad pad; - - private Coroutine stopRumbleAfterTimeCorutine; - - - public void RumblePulse(float lowFrequency, float highFrequency, float duration, int player) - { - pad = Gamepad.all[player]; - if (pad != null) - { - pad.SetMotorSpeeds(lowFrequency, highFrequency); - - stopRumbleAfterTimeCorutine = StartCoroutine(stopRumble(duration, pad)); - } - } - - private IEnumerator stopRumble(float duration, Gamepad pad) - { - float elapsedTime = 0f; - while (elapsedTime < duration) - { - elapsedTime += Time.deltaTime; - yield return null; - } - - pad.SetMotorSpeeds(0f, 0f); - } -} diff --git a/Assets/Scripts/Rumbling/PlayerRumbling.cs b/Assets/Scripts/Rumbling/PlayerRumbling.cs deleted file mode 100644 index d876942..0000000 --- a/Assets/Scripts/Rumbling/PlayerRumbling.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; -using UnityEngine.InputSystem; - -public class PlayerRumbling : MonoBehaviour -{ - [SerializeField] private float RopeRubleTolerance = 0.5f; - - private PlayerInput pInput; - private Gamepad pad; - - // Rope - [SerializeField] private RopeSimulator rope; - - private void Start() - { - Invoke("LateStart", 0.1f); - } - - void LateStart() - { - pInput = GetComponent(); - pad = Gamepad.all.ElementAtOrDefault(pInput.PlayerNum); - if (pad == null) - { - this.enabled = false; - } - - hasInit = true; - } - - bool hasInit = false; - private void Update() - { - if (!hasInit) return; - - var rumble = new RumbleData(); - - float ropeClamed = Mathf.Max(0, rope.Overshoot); - if (ropeClamed > RopeRubleTolerance) - { - float mapped = ropeClamed.Remap(0.5f, 1f, 0f, 1f); - rumble.Max(mapped, mapped); - } - - rumble.Commit(pad); - } -} - -public class RumbleData -{ - private bool modified = false; - private float lowFreq = 0; - private float highFreq = 0; - - public void Max(float low, float high) - { - modified = true; - lowFreq = Mathf.Max(lowFreq, low); - highFreq = Mathf.Max(highFreq, high); - } - - public void Min(float low, float high) - { - modified = true; - lowFreq = Mathf.Min(lowFreq, low); - highFreq = Mathf.Min(highFreq, high); - } - - public void Add(float low, float high) - { - modified = true; - lowFreq += low; - highFreq += high; - } - - public void Commit(Gamepad target) - { - modified = false; - target.SetMotorSpeeds(lowFreq, highFreq); - } -} diff --git a/Assets/Scripts/Rumbling/RopeRumbling.cs b/Assets/Scripts/Rumbling/RopeRumbling.cs new file mode 100644 index 0000000..94d6fd0 --- /dev/null +++ b/Assets/Scripts/Rumbling/RopeRumbling.cs @@ -0,0 +1,48 @@ +using System.Collections; +using System.Linq; +using UnityEngine; +using UnityEngine.InputSystem; + +public class RopeRumbling : MonoBehaviour +{ + [SerializeField] private float RopeRubleTolerance = 0.5f; + [SerializeField] private float MaxVibration = 0.8f; + + private PlayerInput pInput; + private Gamepad pad; + + // Rope + [SerializeField] private RopeSimulator rope; + + private void Start() + { + Invoke("LateStart", 0.1f); + } + + void LateStart() + { + pInput = GetComponent(); + pad = Gamepad.all.ElementAtOrDefault(pInput.PlayerNum); + if (pad == null) + { + this.enabled = false; + } + else + { + + } + + hasInit = true; + } + + bool hasInit = false; + private void Update() + { + if (!hasInit) return; + + float ropeClamed = Mathf.Max(0, rope.Overshoot); + float sensitive_mapped = ropeClamed.Remap(0.2f, 1f, 0f, MaxVibration); + float mapped = ropeClamed.Remap(0.5f, 1f, 0f, MaxVibration); + RumbleManager.StartRumble(-1, sensitive_mapped, mapped, 0.1f); + } +} diff --git a/Assets/Scripts/Rumbling/PlayerRumbling.cs.meta b/Assets/Scripts/Rumbling/RopeRumbling.cs.meta similarity index 100% rename from Assets/Scripts/Rumbling/PlayerRumbling.cs.meta rename to Assets/Scripts/Rumbling/RopeRumbling.cs.meta diff --git a/Assets/Scripts/Rumbling/RumbleManager.cs b/Assets/Scripts/Rumbling/RumbleManager.cs new file mode 100644 index 0000000..995dde0 --- /dev/null +++ b/Assets/Scripts/Rumbling/RumbleManager.cs @@ -0,0 +1,139 @@ +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.InputSystem; + +public class RumbleManager : MonoBehaviour +{ + public static RumbleManager Instance { get; private set; } + + public static Gamepad[] pads; + + private class RumbleEffect + { + public float duration; + public float startTime; + public float lowFreq; + public float highFreq; + + public RumbleEffect(float low, float high, float dur) + { + lowFreq = low; + highFreq = high; + duration = dur; + startTime = Time.time; + } + } + + private static Dictionary> playerRumbles = new Dictionary>(); + + private void Awake() + { + if (Instance == null) + { + Instance = this; + DontDestroyOnLoad(gameObject); + for (int i = 0; i < Gamepad.all.Count; i++) + { + playerRumbles[i] = new List(); // Initialize list for each connected controller + } + } + else + { + Destroy(gameObject); + } + + Invoke("LateStart", 0.1f); + } + + void LateStart() + { + pads = Gamepad.all.ToArray(); + initialized = true; + } + + bool initialized = false; + private void Update() + { + if (!initialized) return; + + foreach (var player in playerRumbles.Keys) + { + UpdateRumble(player); + } + } + + private static void UpdateRumble(int player) + { + if (!playerRumbles.ContainsKey(player) || playerRumbles[player].Count == 0) return; + + float maxLowFreq = 0f; + float maxHighFreq = 0f; + bool shouldRumble = false; + + for (int i = playerRumbles[player].Count - 1; i >= 0; i--) + { + RumbleEffect effect = playerRumbles[player][i]; + if (Time.time - effect.startTime >= effect.duration) + { + playerRumbles[player].RemoveAt(i); + } + else + { + shouldRumble = true; + maxLowFreq = Mathf.Max(maxLowFreq, effect.lowFreq); + maxHighFreq = Mathf.Max(maxHighFreq, effect.highFreq); + } + } + + if (shouldRumble) + { + SetMotorSpeeds(player, maxLowFreq, maxHighFreq); + } + else + { + SetMotorSpeeds(player, 0, 0); // Stop rumbling for this player + } + } + + // Now static, allowing it to be called without an instance + public static void StartRumble(int player, float lowFreq, float highFreq, float duration) + { + if (player == -1) // Target both players + { + foreach (var p in playerRumbles.Keys) + { + StartRumbleForPlayer(p, lowFreq, highFreq, duration); + } + } + else // Target a specific player + { + StartRumbleForPlayer(player, lowFreq, highFreq, duration); + } + } + + private static void StartRumbleForPlayer(int player, float lowFreq, float highFreq, float duration) + { + if (!playerRumbles.ContainsKey(player)) + { + playerRumbles[player] = new List(); + } + playerRumbles[player].Add(new RumbleEffect(lowFreq, highFreq, duration)); + } + + public static void StopAllRumbles(int player) + { + if (playerRumbles.ContainsKey(player)) + { + playerRumbles[player].Clear(); + SetMotorSpeeds(player, 0, 0); // Stop rumbling for this player + } + } + + private static void SetMotorSpeeds(int player, float lowFreq, float highFreq) + { + if (player >= 0 && player < pads.Length) + { + pads[player].SetMotorSpeeds(lowFreq, highFreq); + } + } +} diff --git a/Assets/Scripts/Controller/RumbleManager.cs.meta b/Assets/Scripts/Rumbling/RumbleManager.cs.meta similarity index 83% rename from Assets/Scripts/Controller/RumbleManager.cs.meta rename to Assets/Scripts/Rumbling/RumbleManager.cs.meta index 6c06e72..910ffec 100644 --- a/Assets/Scripts/Controller/RumbleManager.cs.meta +++ b/Assets/Scripts/Rumbling/RumbleManager.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 89c1239a77bb4cc43b1a1552d271ab99 +guid: 6cf314e58a8539a448e6ddeb3ad48149 MonoImporter: externalObjects: {} serializedVersion: 2