3 ms·
With that approach, if you're moving forward, the camera will always be catching up. That means majority of the screen will be taken up with what's behind you,
by jezzamon 3y ago
With that approach, if you're moving forward, the camera will always be catching up. That means majority of the screen will be taken up with what's behind you, whereas as a player you want to see what's in front of you. And that problem gets worse the faster your character is moving (which often happens when the character is falling)
Reading through, I imagine this solution mitigates that somewhat by having velocity as a factor in it.
Another goal in the article is "Move exactly the same with respect to time regardless of frame rate.". Your solution solution doesn't work for variable frame rates in itself, but it's easy to modify it so it does. Here's an example of doing that, just involves calculating the 0.5 factor from a delta time:
https://github.com/Jezzamonn/LD52/blob/b454ebdf9b2406e62ae48b08dbdfc24ed51508f3/src/ts/game/camera.ts#L33 https://github.com/Jezzamonn/LD52/blob/b454ebdf9b2406e62ae48...
For its flaws, what you described is usually what I use in games, though I need to tweak it more. In the last game people said the camera made them feel dizzy :(
- andai 3y agoThanks for the link. util.ts is also very helpful. Also, heh, slurp()
- eternityforest 3y agoWhat if you just change the 0.5 factor based on some function of distance, like maybe the square or 1.5th power, or a hand-tweaked polynomial curve? I suspect something based on real physics would look subtly more natural, but not having a math education I suspect I'd probably try that first, maybe with the addition of some nonsense non-physically-inspired inertia modifier.