Sprite wobbles as it moves.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 9BitStrider

So, I have an interesting glitch, I should say. I’m using a kinematicbody2d for the player. Normally, I don’t notice this during gameplay, except during his slide animation. As the player slides along the floor, his sprite appears to wobble up and down very slightly.

To make it weirder, the issue is only visible when the game is enlarged 2x or higher. At 1x resolution, you can’t tell this is going on. Sub-pixel maybe?

Yes, I have pixel snap on. What else could make my player wobble like that though?

Playing the game at 4x resolution raises the player’s sprite up a half a pixel during the slide.

Very weird...

Full Sized Image

EDIT: Another weird oddity… When I maximize the play field, the jitter goes away entirely…

9BitStrider | 2019-05-30 22:32

I had this problem when drawing text at floating positions, the text was wobbling because it didnt align with screen pixels. I solved it by flooring the position just before drawing (with Vector2.floor()).

I think it wobbles despite pixel snap (which is just an editor option) because your sprite is somehow getting moved slightly up or down at runtime, which makes it no longer match the screen’s pixel grid. So you could also try to floor it, however that might be difficult if that sprite is child of your character…
You should try to print out the global position of the sprite to make sure nothing funny is happening here.

Zylann | 2019-05-31 12:56

Wonder if floor() would work during move_and_slide… I’ll try it in a bit.

I did notice after making collision shapes visible that the entire node wobbles, not just the sprite as I originally thought. I’ll definitely post my results though.

9BitStrider | 2019-05-31 13:26

Yeah… No improvement. It only happenns at 3x, 4x, and full screen though. Perhaps 3.2 will have a fix. Haha.

9BitStrider | 2019-05-31 15:20