Jittering/Wavy Sprite When Moving

I have been working to fix a movement bug for roughly 9 hours.
I have a 8x8 sprite that has a wavy / jittery / shaky motion when moving. I have tried everything; interpolation is on, the sprite itself has no compression and uses point (no filter). I created two movement scripts (using public void FixedUpdate() btw), and both scripts used different ways of moving my sprite. I found that the wavering movement still persisted with both scripts, so I believe the code itself is not the issue.

From my own research, it the bug is caused by one of two things:

1: Bug is caused by problems with pixel snapping, and I need to reconfigure my settings regarding pixel perfect cameras, which I have tried to do but to no avail.

2: It has something to do with the most interesting discovery of my bug fixing quest, which is that the bug is caused by the aspect ratio settings. I created a new project to isolate the problem, with only the player_sprite, movementScript, and Player gameObject. The issue still continues, however if I change my aspect ratio, the flickering / waving movement of the sprite is significantly reduced, if not altogether gone. For instance, on custom (playstation) aspect ratio, 4:3 (320x240), the wavering movement is obvious. When I change the aspect ratio to WXGA (1366x768), the wavy / flickering movement is gone. Using Free Aspect, the wavering/flickering during movement is again obvious.

Video: https://www.youtube.com/watch?v=jbJiJlPz0RA&ab_channel=JohnTerblanche

Yeah it is because of pixel snapping

Btw, when you set the scale to a float like 2.7 like in the youtube video posted, odds are pixel perfect snapping will break because you are trying to display 1 game pixel to 2.7 pixels on the screen etc.

Simple scenario for correct pixel perfect snapping:

  1. Add pixel perfect camera to your main camera, with reference resolution 640x360, ppu 64
  2. Enable grid snapping the scene view’s top left corner with increment of 1/64
  3. Create a 64x64 sprite. This sprite will cover 1 world unit because ppu is 64
  4. Make sure the sprite’s pivot is set to pixels unit instead of normalized(it’ll be at like 32,32 pixel not 3.5, 32.5 etc.)
  5. Drag the sprite into the scene, set the sprite renderer’s sort point to pivot
  6. Set the game view’s resolution to something that is an integer multiple of reference resolution, like 1080p
  7. Move the sprite with your mouse in scene view, observe the sprite is correctly behaving

Cheers

1 Like

Life-saving post, thank you @venediklee. Almost gave up completely on game development.
After hours of searching online through forums and videos, no solutions came even close to the settings you said I should change.

Thanks for the fix.

1 Like

Cheers mate

If you are new to this, I’d suggest making 3d games. 3D tools are much more refined and mainstream

2 Likes