# BUG: RuntimeManager doesn't check for timeScale == 0 when allowNonRigidBodyDoppler is true

**URL:** <https://qa.fmod.com/t/bug-runtimemanager-doesnt-check-for-timescale-0-when-allownonrigidbodydoppler-is-true/20592>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [August 24, 2023, 12:30pm UTC](https://qa.fmod.com/t/bug-runtimemanager-doesnt-check-for-timescale-0-when-allownonrigidbodydoppler-is-true/20592 "2023-08-24T12:30:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lgarczyn](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@lgarczyn](https://qa.fmod.com/u/lgarczyn)\
**Post date:** [August 24, 2023, 12:30pm UTC](https://qa.fmod.com/t/bug-runtimemanager-doesnt-check-for-timescale-0-when-allownonrigidbodydoppler-is-true/20592/1 "2023-08-24T12:30:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [August 25, 2023, 5:48am UTC](https://qa.fmod.com/t/bug-runtimemanager-doesnt-check-for-timescale-0-when-allownonrigidbodydoppler-is-true/20592/2 "2023-08-25T05:48:34Z")

</div>

Hi,

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 `RuntimeManager.cs`

```auto
// From
var velocity = (position - attachedInstances[i].lastFramePosition) / Time.deltaTime;
// Too
var velocity = (position - attachedInstances[i].lastFramePosition) / Mathf.Max(Time.deltaTime, 0.000000001f);

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![lgarczyn](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@lgarczyn](https://qa.fmod.com/u/lgarczyn)\
**Post date:** [August 29, 2023, 6:58pm UTC](https://qa.fmod.com/t/bug-runtimemanager-doesnt-check-for-timescale-0-when-allownonrigidbodydoppler-is-true/20592/3 "2023-08-29T18:58:03Z")

</div>

This would cause a massive spike in calculated velocity.

I simply changed line 470 from

> else

to

> 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

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [August 29, 2023, 11:23pm UTC](https://qa.fmod.com/t/bug-runtimemanager-doesnt-check-for-timescale-0-when-allownonrigidbodydoppler-is-true/20592/4 "2023-08-29T23:23:23Z")

</div>

Hi,

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.
