Hi,
The following code should update a value on the clients with a slight delay. Problem is that on my host client it triggers an infinity loop. Because the setting of the new value for testVariable in the Coroutine triggers another update of testVariable and a call of the OnChange method, which then starts the whole new cycle.
When i set the new value for testVariable directly in the hook method, no update will be triggered, of course.
If I “outsource” the setting of a new value for testVariable to a Coroutine it will trigger an update.
Is this a bug? Or am I doing something wrong here?
[Syncvar (hook="OnChange")]
int testVariable;
OnChange(int value)
{
StartCoroutine(DelayedValueChange());
}
IEnumerator DelayedValueChange()
{
float duration = 0f;
while(duration < 3f)
{
duration += Time.Delta;
yield return null;
}
testVariable = int;
}