MiniGames/Assets/Scripts/SkyWalker/Skywalker_BreakableWall.cs

44 lines
1.3 KiB
C#
Raw Normal View History

2025-09-01 00:01:33 +05:00
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;
2025-09-01 00:01:33 +05:00
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);
});
//});
2025-09-01 00:01:33 +05:00
// Create a sequence
//Sequence seq = DOTween.Sequence();
2025-09-01 00:01:33 +05:00
//// Step 1: Shake
//seq.Append(childMesh.DOShakePosition(shakeDuration).OnComplete(() =>
//{
2025-09-01 00:01:33 +05:00
// // 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);
//});
2025-09-01 00:01:33 +05:00
}
}