From b07650b7f0c0f939418b7a1d67661f3caff1be86 Mon Sep 17 00:00:00 2001 From: Sveske Juice Date: Sat, 3 Feb 2024 22:15:21 -0800 Subject: [PATCH] more damage when swinging --- Assets/Prefabs/Rope.prefab | 25 +++++++++++++++++++++++++ Assets/Scripts/Rope/RopeSimulator.cs | 6 +++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Assets/Prefabs/Rope.prefab b/Assets/Prefabs/Rope.prefab index 49ac832..48d61c6 100644 --- a/Assets/Prefabs/Rope.prefab +++ b/Assets/Prefabs/Rope.prefab @@ -66,9 +66,34 @@ MonoBehaviour: ropeExtendSpeed: 10 ropeShrinkSpeed: 15 squezeDamage: 1 + swingSpeedToDamageMultiplier: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0.39527363 + outSlope: 0.39527363 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0.04244307 + - serializedVersion: 3 + time: 30 + value: 5 + inSlope: 0.01896792 + outSlope: 0.01896792 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.066252515 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 ropeMaxLength: 50 ropeMinLength: 20 lineRenderer: {fileID: 901761791259710742} + pullAnimationOvershootThreshold: 0.2 --- !u!120 &901761791259710742 LineRenderer: serializedVersion: 2 diff --git a/Assets/Scripts/Rope/RopeSimulator.cs b/Assets/Scripts/Rope/RopeSimulator.cs index dd276b2..aec8193 100644 --- a/Assets/Scripts/Rope/RopeSimulator.cs +++ b/Assets/Scripts/Rope/RopeSimulator.cs @@ -54,6 +54,7 @@ public class RopeSimulator : MonoBehaviour public float ropeExtendSpeed, ropeShrinkSpeed; public float squezeDamage = 1f; + public AnimationCurve swingSpeedToDamageMultiplier; [SerializeField] public float ropeMaxLength, ropeMinLength; @@ -68,6 +69,7 @@ public class RopeSimulator : MonoBehaviour int[] order; public float Overshoot => rope.CalculateLengthOvershoot(); + public bool InSwingMode => start.locked || end.locked; public Rope rope; @@ -295,7 +297,9 @@ public class RopeSimulator : MonoBehaviour if (squezeDamageReceiver == null) continue; - squezeDamageReceiver.TakeSquezeDamage(collider.Value * squezeDamage); + + float swingMultiplier = InSwingMode ? swingSpeedToDamageMultiplier.Evaluate((start.locked ? end : start).body.velocity.magnitude) : 1f; + squezeDamageReceiver.TakeSquezeDamage(collider.Value * squezeDamage * swingMultiplier); } // Update line renderer