Predicted Timer Module
Basic Usage
public class Bomb : PredictedIdentity
{
private TimerModule _fuseTimer;
protected override void LateAwake()
{
// Create the timer (default: automatic countdown)
_fuseTimer = new TimerModule(this);
// Hook into events
_fuseTimer.onTimerEnded += Explode;
_fuseTimer.onPredictedTimerUpdated_View += UpdateTimerUI;
}
public void Activate()
{
// Only the server (or owner, if allowed) needs to start it
if (isServer)
_fuseTimer.StartTimer(5.0f);
}
private void Explode() { /* Boom */ }
private void UpdateTimerUI(float timeRemaining)
{
// Use the event value for smooth UI updates
_uiText.text = timeRemaining.ToString("F1");
}
}Manual Ticking
API References
Last updated