Open musjj opened 3 months ago
I can't replicate it myself (which browser are you using?) but my intuition says it's about the frame duration getting too big after the focus returns. And the video confirms it - but I also see the long frame time when I run it, and I don't see the behavior on my character...
The original VVV video mentioned capping the boosts, but I think it would make more sense to cap the frame duration (so that even if a single frame took 5 minutes, Tnua will pretend it only took, say, 500ms). But before I try that, I want to try something else. Currently the spring force is boost-based - I want to try and change it to be acceleration based. The physics engine handles these much better than it handles boosts, especially when the frame duration is irregular.
@musjj - try the web demo now please. I've changed the spring impulse from boost to acceleration, which I think should solve the issue. Tell me if it works (since I can't replicate the problem on my machine)
Thanks, it looks like the issue no longer happens in the web version! But trying the latest commit on my project causes my character to sink and become unmovable. I'll look into it a bit more.
Are you applying forces on the character using Avian's API? It's possible that you are overwriting the ones Tnua (now) uses to keep the character afloat.
When you unfocus and then refocus the game's window, the character controller sometimes bounces a bit. It looks like that the force that floats the character gets re-applied for some reason. I don't have a consistent way to reproduce it currently.
But the issue also sometimes happens with the web demo. If I leave the tab for long enough, switching back to it can sometimes cause the character to leap all the way up off-screen before dropping back down.
EDIT: Captured it on video (ignore the weird colors, something went wrong with the encoding):
https://github.com/user-attachments/assets/8aba0f19-c01d-48de-ba4b-4f97db7a064e