Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Is Pixel Perfect movement compatible with Unity physics?

Discussion in '2D' started by CPTANT, Jun 10, 2023.

  1. CPTANT

    CPTANT

    Joined:
    Mar 31, 2016
    Posts:
    80
    Hi guys, I have a question.

    I am trying to get pixel perfect movement in my game. I have tried to use the pixel perfect camera for this, but the clamping seems to result in a lot of jittering. I think the problem is that the player and camera are both moving, resulting in inconsistent rounding. I am thinking the best way to solve this is to actually have the player move in pixel increments. I know that I can do this by storing subpixels and moving the player, however I also have 2d Unity physics in the game. Would there be any good way to combine these two? Or is there actually a different approach that results in smooth pixel movement?
     
  2. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    the physics will behave the same whether your game is pixel perfect or not, all that changes is how sprites are displayed
     
  3. venediklee

    venediklee

    Joined:
    Jul 24, 2017
    Posts:
    143
    This probably means your pixel perfect setup is wrong, please check out this manual page.

    Another cause could be that your pixels are too large and when the camera moves it has to move in large increments, resulting in jittery feeling.

    I’d recommend just testing it in an empty project, takes like 10 minutes.

    and yes physics is not dependent on pixel perfect setup
     
    Kurt-Dekker likes this.