#(Beginner here) How would I go about solving a jittery camera issue like this?

5 messages · Page 1 of 1 (latest)

snow tartan
#

it's probably an issue with rounding

you are trying to move your object in increments of 0.5 but with pixels and your display size, you can't draw something halfway into a pixel.

so each frame it's prob jumping between rounding and not as you jump between 0.5 1 1.5 2
and it's making your object jitter back and forth.

From my experience, 0.5 is like the worst increment you can put something in that has a camera following. I'd do 0.4 or 0.6 and maybe floor the x value when drawing it.

#

subpixel movement is a fiddly thing to get right if you don't have your viewport set up to draw subpixels

snow tartan
#

ah glanced at your code and saw that 0.5 in the clamp without reading all of the context lol
still, same concept for what causes that jitter.

looking closer you are still moving the camera in non-integer amounts too
what speed is your player object moving at?

#

yeah then it's your easing code, again the camera can't be placed at an x of 10.4
so it's gonna round up or down
the jitter is usually from it alternating between rounding up and down in odd patterns

maybe wrap it in a floor((x_dest - x) / 8)
to always round down or tweak the numbers

snow tartan
#

maybe try a lerp there with 0.4 or something