Netick is a state transfer Unity netcode. This TickTimer is inspired by Photon Fusion TickTimer
TickTimer is a plugin wrapper that counts if the tick we are targeting has been passed, rather than decrementing a float with deltaTime.
[Networked] private TickTimer _destroyTimer { get; set; }
private float _delay = 5f;
public override void NetworkStart()
{
_destroyTimer = TickTimer.CreateFromSeconds(Sandbox, _delay);
}
public override void NetworkFixedUpdate()
{
if (_destroyTimer.IsExpired(Sandbox))
{
_destroyTimer = TickTimer.None;
Sandbox.Destroy(Object);
}
}| Timers | Description |
|---|---|
| TickTimer | Uses predictive tick if available. Most recommended way to sync timers |
| AuthTickTimer | Uses the server tick. Good for non-predictive stuff |
| PauseableTickTimer | Can be paused across the network |
| API | Description |
|---|---|
| IsRunning | Has a valid Target Tick |
| IsExpired | Has passed the target Tick |
| IsExpiredOrNotRunning | Either has passed the target Tick, or it wasn't set |
| GetAlpha | Get the progress to the target tick |
| GetAlphaClamped | Get the progress to the target tick (clamped to 1) |