Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Moving the camera in a pixel perfect pixel art game

Discussion in '2D' started by Mako23, Sep 8, 2019.

  1. Mako23


    Sep 7, 2015
    I have been trying to figure out pixel perfect movement in Unity for a while no with little to no success. Well, after fiddling around for several nights, my game is pixel perfect and movements are smooth BUT once the camera moves, all hell breaks loose.

    My tile size is 16x16 that is my PPU on every sprite, the pixel perfect camera etc.

    What I did so far:

    - set all sprites to what official Unity Blogposts suggest: 16 ppu, no compression, point filter

    - installed the pixel perfect camera picture, tried several retro resolutions 256×224 , 256x144 , and even 720x480

    - enabled pixel snap on the material (honestly, with the pixel camera this hardly does anything)

    - I read into how they moved the sprites in super mario land on the snes, the basically divide each pixel into subpixels and move their character in a virtual position and align it to the closest pixel on the grid, that what I do, and characters now move pixel perfect across the screen (this and the pixel perfect camera component have given the best results by far)

    - disabled anti aliasing

    - turned off vysnc and locked the fps to 60

    With all this in place, the game looks crisp, movement is smooth and pixel perfect BUT once I move the camera, there is distortion, stutter and artifacts. It is especially bad when moving diagonally. I tried locking the camera position to the closest pixel but this doesn't help. I just don't know what to try anymore. I know it can be done, I just don't know how.

    All the code can be found here:
    It's messy and all over the place because at this point I have just been experimenting, trying to see what works and what doesn't. I'd be so happy if anybody could help!