using UnityEngine; using DG.Tweening; // DOTween public class Skywalker_BreakableWall : MonoBehaviour { public bool requiresCharge = true; public float shakeDuration = 0.2f; // how long the shake lasts public float breakDuration = 0.5f; // how long the shrink lasts public float shrinkScale = 0.1f; // final scale when shrinking private bool isBreaking = false; public void BreakWall() { if (isBreaking) return; isBreaking = true; // Create a sequence Sequence seq = DOTween.Sequence(); // Step 1: Shake seq.Append(transform.DOShakePosition(shakeDuration, strength: 0.2f, vibrato: 10, randomness: 90)); // Step 2: Shrink down seq.Append(transform.DOScale(Vector3.one * shrinkScale, breakDuration).SetEase(Ease.InBack)); // Step 3: Destroy at the end seq.OnComplete(() => { Destroy(gameObject); }); } }