More robust version of OnChanged?
I'm trying to use OnChanged property to spawn visuals when an object is destroyed/restored, simplified it looks like this:
[Networked(OnChanged = nameof(OnAliveChanged))] public bool alive { get; set; }
private static void OnAliveChanged(Changed<Part> changed) {
changed.Behaviour.OnAliveChanged();
}
private void OnAliveChanged() {
if(alive) SpawnRestoreEffect();
else SpawnDestroyEffect();
}
The problem here is that Fusion will often flip back and forth multiple times whenever a change occurs, so when the part is destroyed it will SpawnDestroy, SpawnRestore on the next tick and SpawnDestroy again on the tick after that, so the effects start mixing in a way I want to avoid.
Is there a way to prevent that from happening, to say only call OnChanged when the change has been confirmed over the network?
Am I using the wrong approach here?