Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller bounces when refocusing window #56

Open
musjj opened this issue Jul 31, 2024 · 4 comments
Open

Controller bounces when refocusing window #56

musjj opened this issue Jul 31, 2024 · 4 comments

Comments

@musjj
Copy link

musjj commented Jul 31, 2024

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):

output.mp4
@idanarye
Copy link
Owner

idanarye commented Aug 6, 2024

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.

@idanarye
Copy link
Owner

idanarye commented Aug 6, 2024

@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)

@musjj
Copy link
Author

musjj commented Aug 6, 2024

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.

@idanarye
Copy link
Owner

idanarye commented Aug 6, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants