20 lines
425 B
C#
20 lines
425 B
C#
using UnityEngine;
|
|
|
|
public class HoldTimer
|
|
{
|
|
private float targetTime;
|
|
private float currentTime;
|
|
|
|
public HoldTimer(float target) => targetTime = target;
|
|
|
|
public bool Update(bool isHolding)
|
|
{
|
|
currentTime = isHolding
|
|
? Mathf.Min(currentTime + Time.deltaTime, targetTime)
|
|
: 0;
|
|
return currentTime >= targetTime;
|
|
}
|
|
|
|
public void Reset() => currentTime = 0;
|
|
}
|