How do I make pixel rounding diagonal movement not jitter?

0 favourites
  • 10 posts
From the Asset Store
A template for a grid movement , grid tactics type game like Dofus , click on the grid you want to move to and the
  • Hi,

    I want to use pixel rounding for a demo I'm making, as the demo utilizes pixel art. The player moves in 8 directions, and the 4 cardinal directions are smooth both with and without pixel rounding.

    However, when it comes to diagonal movement, pixel rounding causes the screen to jitter.

    It works completely fine without pixel rounding.

    How do I make diagonal movement with pixel rounding not jitter?

  • As I understand you have a camera issue? If so you might want to create a new camera object that has the "Scroll to" behavior and lerp it to the player.

    Every tick ->

    Set camera position to ->

    x -> lerp( Self.X, Player.X, 3 * dt )

    y -> lerp( Self.Y, Player.Y, 12 * dt )

  • As I understand you have a camera issue? If so you might want to create a new camera object that has the "Scroll to" behavior and lerp it to the player.

    Every tick ->

    Set camera position to ->

    x -> lerp( Self.X, Player.X, 3 * dt )

    y -> lerp( Self.Y, Player.Y, 12 * dt )

    The problem is, I don't want a camera that lags behind the player either. I want it to lock to exactly their position and also not jitter.

  • Have you tried lowering increasing the percentage value like

    x -> lerp( Self.X, Player.X, 100 * dt )

    y -> lerp( Self.Y, Player.Y, 100 * dt )

    Then it will stay really tight yet it might be enough to not jitter.

  • https://www.construct.net/en/game-assets/game-templates/pixel-perfect-resolution-554

  • Have you tried lowering increasing the percentage value like

    x -> lerp( Self.X, Player.X, 100 * dt )

    y -> lerp( Self.Y, Player.Y, 100 * dt )

    Then it will stay really tight yet it might be enough to not jitter.

    Tried this, though the camera is super snappy on startup, and the jittering still occurs.

    https://www.construct.net/en/game-assets/game-templates/pixel-perfect-resolution-554

    This is exactly what I'd like to happen in my demo. Unfortunately, given my interests I don't think I'll be able to sink so much money into just a demo.

  • Try this custom movement with a direct camera follow. The movement makes sure that the player only moves to rounded pixel positions (hence the camera does also). It seems to me that when using a movement behaviour like 8-dir the engine has to reconcile non pixel rounded movement and then, if pixel rounding is used, pixel rounded rendering. To me it seems that it is this step that causes the jitter.

    You can turn pixel rounding on or off with no difference in result in this case as the camera and objects are always moved to a whole pixel location. However if you had parallax layers with different rates etc. you could turn pixel rounding on.

    1drv.ms/u/s!AkmrWgxeuxlKhIg64vXcO8gf8jJB7w

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Try this custom movement with a direct camera follow. The movement makes sure that the player only moves to rounded pixel positions (hence the camera does also). It seems to me that when using a movement behaviour like 8-dir the engine has to reconcile non pixel rounded movement and then, if pixel rounding is used, pixel rounded rendering. To me it seems that it is this step that causes the jitter.

    You can turn pixel rounding on or off with no difference in result in this case as the camera and objects are always moved to a whole pixel location. However if you had parallax layers with different rates etc. you could turn pixel rounding on.

    https://1drv.ms/u/s!AkmrWgxeuxlKhIg64vXcO8gf8jJB7w?e=6kYwLQ

    This is great, but I also need the 8-Direction behavior due to its ability to detect Solids, something this project doesn't have.

  • You can add in that functionality with simple events.

    1drv.ms/u/s!AkmrWgxeuxlKhIg64vXcO8gf8jJB7w

    Redownload it again

  • You can add in that functionality with simple events.

    https://1drv.ms/u/s!AkmrWgxeuxlKhIg64vXcO8gf8jJB7w?e=K9nlCj

    Redownload it again

    Decent, but doesn't function well with dynamic movement speed (I have a running function that makes the player move at x2 speed, which messes with this.) All in all, I feel like keeping the 8-Direction behavior is best due to its collision detection.

    The most I want to do is make it not jitter when moving diagonally.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)