james7132 / DanmakU

An open source Danmaku development kit for Unity3D.
https://danmaku.jamessliu.com/
MIT License
238 stars 50 forks source link

Disabling one DanmakuEmitter / changing frame rate causes bullet rendering issues #39

Closed crazoter closed 6 years ago

crazoter commented 6 years ago

This problem can be replicated in a few ways:

  1. Using the Test Scene, enable both emitters and set the frame rate of one the emitters to something like 9999 while the other can be left at 0. After some time, bullets by the other emitter will disappear before reappearing when the 9999 frame rate emitter starts shooting again.

  2. Disable one of the emitters after it has been shooting for awhile. Bullets by other emitters will also disappear until the disabled emitter is re-enabled.

Technically, the other emitters are still enabled and will still continue to run their own Update() and call their own fireable.Fire(). In fact, their bullets are still in existence and collisions by these danmaku will still register with DanmakuColliders and trigger OnDanmakuCollision (even though you can't see them).

However, all bullets will no longer be rendered while any one of these emitters are disabled / "lagging".

crazoter commented 6 years ago

lol, I had spent a few hours trying to figure this bug out but just minutes after posting this issue I found the solution.

DanmakuRenderer.cs Line 76

if (pool == null || pool.ActiveCount <= 0) return;
TO
if (pool == null || pool.ActiveCount <= 0) continue;

Solves this issue.