more damage when swinging

This commit is contained in:
Sveske Juice 2024-02-03 22:15:21 -08:00
parent 71c1471a4e
commit b07650b7f0
2 changed files with 30 additions and 1 deletions

View File

@ -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

View File

@ -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