Mini demo with all features
This commit is contained in:
@@ -56,25 +56,6 @@ public class ArmEquipment
|
||||
[Tooltip("Curve for transition movement")]
|
||||
public AnimationCurve TransitionCurve = AnimationCurve.EaseInOut(0, 0, 1, 1);
|
||||
|
||||
[Header("Tap Animation")]
|
||||
[Tooltip("Elbow rotation during windup (degrees)")]
|
||||
public float TapWindupRotation = 15f;
|
||||
|
||||
[Tooltip("Duration of windup (pull back)")]
|
||||
public float TapWindupDuration = 0.1f;
|
||||
|
||||
[Tooltip("Duration of strike (forward snap)")]
|
||||
public float TapStrikeDuration = 0.05f;
|
||||
|
||||
[Tooltip("Wrist snap rotation during strike (degrees)")]
|
||||
public float TapWristSnapRotation = 10f;
|
||||
|
||||
[Tooltip("Shake intensity during vibration")]
|
||||
public float ShakeIntensity = 2f;
|
||||
|
||||
[Tooltip("Shake speed (frequency)")]
|
||||
public float ShakeSpeed = 30f;
|
||||
|
||||
[HideInInspector] public ArmState State = ArmState.Environmental;
|
||||
[HideInInspector] public Vector3 OriginalTargetPosition;
|
||||
[HideInInspector] public Quaternion OriginalTargetRotation;
|
||||
@@ -92,6 +73,7 @@ public class ArmEquipment
|
||||
|
||||
private int _tapTweenId = -1;
|
||||
private bool _isShaking = false;
|
||||
private TapAnimationSettings _currentShakeSettings;
|
||||
|
||||
private Quaternion _transitionStartShoulder;
|
||||
private Quaternion _transitionStartElbow;
|
||||
@@ -376,9 +358,9 @@ public class ArmEquipment
|
||||
_isShaking = false;
|
||||
}
|
||||
|
||||
public void PlayTapAnimation()
|
||||
public void PlayTapAnimation(TapAnimationSettings settings)
|
||||
{
|
||||
if (State != ArmState.Equipped)
|
||||
if (State != ArmState.Equipped || settings == null)
|
||||
return;
|
||||
|
||||
if (_tapTweenId != -1)
|
||||
@@ -389,13 +371,13 @@ public class ArmEquipment
|
||||
Quaternion elbowStart = ElbowBone != null ? ElbowBone.localRotation : Quaternion.identity;
|
||||
Quaternion wristStart = WristBone != null ? WristBone.localRotation : Quaternion.identity;
|
||||
|
||||
Quaternion elbowWindup = elbowStart * Quaternion.Euler(0, 0, -TapWindupRotation);
|
||||
Quaternion elbowStrike = elbowStart * Quaternion.Euler(0, 0, TapWindupRotation * 0.3f);
|
||||
Quaternion elbowWindup = elbowStart * Quaternion.Euler(0, 0, -settings.WindupRotation);
|
||||
Quaternion elbowStrike = elbowStart * Quaternion.Euler(0, 0, settings.WindupRotation * 0.3f);
|
||||
|
||||
Quaternion wristWindup = wristStart;
|
||||
Quaternion wristStrike = wristStart * Quaternion.Euler(0, 0, -TapWristSnapRotation);
|
||||
Quaternion wristStrike = wristStart * Quaternion.Euler(0, 0, -settings.WristSnapRotation);
|
||||
|
||||
_tapTweenId = LeanTween.value(IkLimb.gameObject, 0f, 1f, TapWindupDuration)
|
||||
_tapTweenId = LeanTween.value(IkLimb.gameObject, 0f, 1f, settings.WindupDuration)
|
||||
.setOnUpdate((float t) => {
|
||||
if (ElbowBone != null)
|
||||
{
|
||||
@@ -407,7 +389,7 @@ public class ArmEquipment
|
||||
}
|
||||
})
|
||||
.setOnComplete(() => {
|
||||
_tapTweenId = LeanTween.value(IkLimb.gameObject, 0f, 1f, TapStrikeDuration)
|
||||
_tapTweenId = LeanTween.value(IkLimb.gameObject, 0f, 1f, settings.StrikeDuration)
|
||||
.setOnUpdate((float t) => {
|
||||
if (ElbowBone != null)
|
||||
{
|
||||
@@ -437,22 +419,24 @@ public class ArmEquipment
|
||||
}).id;
|
||||
}
|
||||
|
||||
public void StartShake()
|
||||
public void StartShake(TapAnimationSettings settings)
|
||||
{
|
||||
_isShaking = true;
|
||||
_currentShakeSettings = settings;
|
||||
}
|
||||
|
||||
public void StopShake()
|
||||
{
|
||||
_isShaking = false;
|
||||
_currentShakeSettings = null;
|
||||
}
|
||||
|
||||
public void UpdateShake()
|
||||
{
|
||||
if (!_isShaking || State != ArmState.Equipped || WristBone == null)
|
||||
if (!_isShaking || State != ArmState.Equipped || WristBone == null || _currentShakeSettings == null)
|
||||
return;
|
||||
|
||||
float shake = Mathf.Sin(UnityEngine.Time.time * ShakeSpeed) * ShakeIntensity;
|
||||
float shake = Mathf.Sin(UnityEngine.Time.time * _currentShakeSettings.ShakeSpeed) * _currentShakeSettings.ShakeIntensity;
|
||||
Quaternion shakeRotation = Quaternion.Euler(shake, shake * 0.5f, 0);
|
||||
|
||||
Quaternion targetRot = OriginalWristRotation * Quaternion.Euler(WristRotationOffset) * shakeRotation;
|
||||
|
||||
Reference in New Issue
Block a user