38 lines
776 B
C#
38 lines
776 B
C#
using UnityEngine;
|
|
|
|
public class ShieldScaleUp : MonoBehaviour
|
|
{
|
|
[Tooltip("Time it takes to fully grow the shield")]
|
|
public float growDuration = 0.5f;
|
|
|
|
[Tooltip("Curve to control growth speed over time")]
|
|
public AnimationCurve scaleCurve = AnimationCurve.EaseInOut(0, 0, 1, 1);
|
|
|
|
private float timer = 0f;
|
|
private Vector3 targetScale;
|
|
|
|
private void Awake()
|
|
{
|
|
targetScale = transform.localScale;
|
|
transform.localScale = Vector3.zero;
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
timer = 0f;
|
|
transform.localScale = Vector3.zero;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (timer < growDuration)
|
|
{
|
|
timer += Time.deltaTime;
|
|
float t = Mathf.Clamp01(timer / growDuration);
|
|
|
|
float scaleValue = scaleCurve.Evaluate(t);
|
|
|
|
transform.localScale = targetScale * scaleValue;
|
|
}
|
|
}
|
|
} |