MiniGames/Assets/Scripts/SkyWalker/Skywalker_BreakableWall.cs
2025-09-16 17:51:02 +05:00

44 lines
1.3 KiB
C#

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 Transform childMesh;
public void BreakWall()
{
if (isBreaking) return;
isBreaking = true;
//childMesh.DOShakePosition(shakeDuration,strength: 0.005f, vibrato: 10, randomness: 45).OnComplete(() =>
//{
childMesh.DOScale(Vector3.one * shrinkScale, breakDuration).SetEase(Ease.InOutBack).OnComplete(() =>
{
Destroy(gameObject);
});
//});
// Create a sequence
//Sequence seq = DOTween.Sequence();
//// Step 1: Shake
//seq.Append(childMesh.DOShakePosition(shakeDuration).OnComplete(() =>
//{
// // Step 2: Shrink down
// seq.Append(childMesh.DOScale(Vector3.one * shrinkScale, breakDuration).SetEase(Ease.InBack));
//});
//// Step 3: Destroy at the end
//seq.OnComplete(() =>
//{
// Destroy(gameObject);
//});
}
}