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

Physics Engine linked to Framerate #40

Open
TheYellowArchitect opened this issue Aug 12, 2022 · 0 comments
Open

Physics Engine linked to Framerate #40

TheYellowArchitect opened this issue Aug 12, 2022 · 0 comments
Labels
high priority Very important, heavily influences the game, must be looked ASAP player movement Anything related to the core movement of the player (e.g. velocity or acceleration or animationcanc)

Comments

@TheYellowArchitect
Copy link
Owner

The cardinal sin of gamedev.
I even knew about how bad it is to link framerate with physics, when I was writing the velocity system, yet I kept going because:
"Smash Bros runs at consistent 60 FPS, and surely Double Damnation can also run at consistent 60 FPS even in a shitty laptop"
The above was true at the time (2018), but I was so naive back then, thinking I had the feature-scale all figured out, when when I was still a newbie in programming (less than a year of programming!)

Every .velocity calculation ofc uses * Time.unscaledDeltaTime
So, where is the problem?
In my physics. Unity has no default acceleration values (it has velocity and force, but no acceleration), so I made my own, in order to recreate the DI (Directional Influence) feature from Smash Bros.
A blessing in disguise, as I implemented it for damage, but expanding it, I made Double Damnation have the unique and freeflow movement it is known for, today.
BUT. The acceleration increases per frame (this is why in speedruns, the lower framerate makes you faster, as less friction happens)
So, to solve this, I could go on acceleration (in-code, it is influenceX), and do * Time.unscaledDeltaTime
And indeed, it should become "framerate independent"

But since Time.unscaledDeltaTime is 0.0016 in 60 FPS, obviously the acceleration drops heavily, and the end result is not the same.
Hence, I must add a constant/hardcoded variable that when multiplied by 0.0016, returns the exact same values as current.

Why don't I do that?
Because it would take 1~3 days of playtesting, to get the exact value, and ensure the movement system will be the EXACT SAME as previous versions on 60 FPS (no movement regression, rip speedruns)
Its a boring process - I will do it eventually - but until then, I have my eyes on more important things.

@TheYellowArchitect TheYellowArchitect added player movement Anything related to the core movement of the player (e.g. velocity or acceleration or animationcanc) high priority Very important, heavily influences the game, must be looked ASAP labels Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high priority Very important, heavily influences the game, must be looked ASAP player movement Anything related to the core movement of the player (e.g. velocity or acceleration or animationcanc)
Projects
None yet
Development

No branches or pull requests

1 participant