Day Sixty Eight
Well, I spent 2.5 of today’s 0.5 hours working on the game fixing a major bug 😬 low framerates (~40fps or lower), where the time between frames is at least double the time between fixed update frames, cause bullets to collide twice. That means the player deals double damage against the bosses, which is terrible for a number of reasons. The flag for the bullet being killed isn’t updated until the next real frame redraw, and the bullet isn’t moved until the next real frame redraw, so if two physics updates happen in the same visual frame the game will register that collision twice.
This has been something of a headache to work my brain through, what you’re reading here is the culmination of many hours of trying to process what’s going on - with the help of @ktyl on the Wayfarer Games Discord server 😄 and even that explanation requires a bunch of knowledge about how Unity works. To be perfectly honest, it was a real effort to work out what was even happening in the first place! There’s a double damage cheat, which I assumed was the actual problem. Once you get in your head that a problem is caused by a specific thing, you lose a lot of time trying to engineer solutions to work around that thing - which ultimately gets you nowhere because it wasn’t even the cause anyway!
It’s tough to let go of things like that, but this could’ve lasted a LOT longer. I’m quite impressed that we found the cause (low FPS) as quickly as we did, given how tightly I was holding on to it being the fault of the cheat code… The virtual machine is what did it in the end. I actually managed to get triple damage because the VM ran at such a low framerate that three fixed updates were happening in the same visual update. Working out how to fix it was another challenge, but I could simulate the issue by setting Application.targetFramerate to something low enough, which made testing things much easier. I’m probably going to have to run it at low FPS consistently during my testing to make sure there are no other issues like this, so I’ve added a keyboard shortcut.
Oh, and my hacky solution was to just do bullet collision checks in Update instead of Fixed Update. Once Polyfury is released, I’ll go back and fix it properly in BulletFury, and probably Polyfury too with the inevitable post-release bugfix update. Now I’ve worked out what’s actually happening and why, it should be relatively easy to solve.
What’s next?
Heptagram tomorrow. For reals this time.
I hope you enjoyed reading about my Polyfury progress. If you have any questions or thoughts, please feel free to leave a comment below. Thanks for reading, and maybe check out the demo: