I’ve started using allowNonRigidBodyDoppler, but as soon as the game is paused, I start getting thousands of errors due to the calculated velocity being NaN.
This is caused by a division by zero, since the position diff is divided by Time.timeScale
The correct behavior would be to simply not update the velocity attribute when timeScale is 0.
The only current solutions are to not use AttachInstanceToGameObject with allowNonRigidbodyDoppler, or to disable the RuntimeManager on pausing.
Thank you for bringing this to our attention.
I have passed this on to our development team to resolve.
In the meantime, a workaround is changing line
475 in the
var velocity = (position - attachedInstances[i].lastFramePosition) / Time.deltaTime;
var velocity = (position - attachedInstances[i].lastFramePosition) / Mathf.Max(Time.deltaTime, 0.000000001f);
Hope this helps.
This would cause a massive spike in calculated velocity.
I simply changed line 470 from
else if (Time.deltaTime > 0f)
This simply does not update the velocity for allowNonRigidbodyDopper events when the game is paused, which is the same behavior as normal doppler
You are correct, this is the better solution. The fix will be in the next release.
Again, thank you for bringing this to our attention.