2D pixelart game is laggy and tiles are jittering!

Hi there,

I’ve been trying to create 2D RPG game. I got stuck at something thats getting on my nerves for long time…
When i play game, and start moving, my tiles - terrain gets blurry and everything seem laggy(but animations are ok!).

something like this:
NmDBKKKgK390ACZSGc


Pixels gets distorted and some of them are duplicated, its easy for a player to see especially because my isometric blocks has black outline…

I am looking for way to fix that jittering and lag, make my gameplay smooth as much as I can (like other 2D pixelart games) and make a feeling like you have 60+ fps, not 20 :'d.
Also i tried using PixelPerfect2D and extension too, with all possible settings but no help at all…It can only get worse… :c Also tried variety of clips on YT and read tons of forum threads before posting this, so this is only way I can get help!

Here is a video so you can try and understand what I am trying to solve:

https://vimeo.com/928842193

note: keep in mind that this tiny gameplay is in 60fps, but you can see “lag”…
Thanks!

Honestly, unity should add a “follow these steps or wrong pixels etc.” warning to the pixel perfect camera

Try these to fix pixel alignment, non pixel perfect feel, 2d pixel jitter etc. issues(works without pixel perfect camera component too)

For the “lag”, it might be your project/code or the side effect of pixel jitter when moving

It is definitely possible to make a smooth pixel perfect camera with high fps, it just needs a bit extra attention.

1 Like

wish something like that exist :slight_smile:

Thank you for answer!
Your guide really DID help me get it really smoother, less lag, but it still exist! Black outlines still getting thicker and thinner…
like i need some sort of Vsync hmm…
Should I give you my movement code if you think that can cause rest of “lags”?
Thanks again!

this is probably because your camera is a child of your character and you move your character non-pixel perfectly

Try this camera follow script:
https://gist.github.com/venediklee/1437f3c908cc135be10c4ddb2f23bec9

this stops my movement on character. Its stuck to its starting position, cant move.

Before your script i was using Cinemachine, that was not child of my Character.

Ah, sorry for not clarifying

you are supposed to remove cinemachine follow stuff, remove the camera from the children of the player(if it is a child of the player) and add the given script to the camera

Ohh i did that of course, but no movement at all.
Actually i cant find in this code inout part?
And is it possible to make cinemachine perfect for pixelart?

You must have made a mistake, here is everything you need to do step by step:

  • disable everything related to cinemachine in the test scene
  • make the camera’s parent null
  • add the PixelPerfectPlayerFollower script to the camera
  • if your player(the one that moves) isn’t the only gameobject that has the player tag, make the _player field of PixelPerfectPlayerFollower public or [SerializeField], and assign the player in the editor to PixelPerfectPlayerFollower component of the camera
  • change the other exposed fields of the camera such that it fits your project. For example if your project’s ppu is 128, set the ppu field of the PixelPerfectPlayerFollower to 128 etc.
  • Make sure your game view is in 1x and actual integer multiple of base resolution is selected
  • enter play mode, move the player(either with your code or dragging in scene); observe the camera smoothly following the player

Here is how the PixelPerfectPlayerFollower script works in my game:

Cheers

dont use cinemachine, it makes all the effects that you described

Thanks both for your time!
I managed to use your script as following camera, but no improvements.
Those black lines really persistent!

https://vimeo.com/929035444

you should take a video with screen capture like OBS studio, and catch the frames where you think there is jitter

if you can only see jitter if you film your screen with your phone, then its the problem of your screen

monitor is absolutely fine, its brand new.
i posted a video above, in first question. Also i see jittering when i play, when i export game and play it, but when i record it with OBS and watch it, i do not see it.

It’s nothing to do with how new it is. This is a fundamental artefact of any display device and it’s know as its response time also related to its refresh rate frequency.

Showing that this is nothing to do with 2D or Unity.

Use sites like the following to test your monitor:
https://www.testufo.com/
https://www.testufo.com/mprt
https://www.testufo.com/blurtrail

Imgur
Imgur

Why are you posting screenshots?

I feel you don’t understand the difference between what Unity renders that you can capture digitally via the OS (screenshot, OBS etc) i.e. capturing the frame-buffer and what you capture with an external camera of the display device i.e. capturing what is being displayed. Only with an external camera will you be able to capture any blur (etc). A device such as your eyes too obviously.

Don’t confuse motion bluring with other rendering artefacts such as not updating the scene in a consistent way. Words such as “blur”, “lag” and “jitter” are often used by different people to mean different things. If rendering isn’t consistent then that is completely different than motion bluring that the display device produces due to its response time.

If there’s inconsistent updates due to something in your scripts then that can be figured out here but response time issues cannot be solved. :slight_smile:

I dont understand why you send me links of monitor testers if it does not help you resolve my problem?
I also dont get how can I explain to you that I am playing much much demanding games, and you are telling me that my monitor cant run a 5 lines of code, 32px game?

This has nothing to do with my monitor, nor PC…
I have never experienced such a similar problem with anything else.
I tried making multiple projects (non - pixelart)
and I have not encountered a similar problem.

Thanks for help!

Believe it or not, i do actually :"d

I explained above why so please take the time to read it. You seem to be annoyed at me trying to delineate between visual artefacts that cannot be resolved here and actual things that can be resolved as it relates to what is being rendered inside the framebuffer.

This is why I responded because this proves that the specific issue you’re referring to isn’t what is being rendered but is your display device.

“Jitter” or inconsistent motion is not the same as motion blur. Distinguishing between the two is important and is helping as it’s getting to what can and cannot be solved.

“Those Black Lines” are motion blur and cannot be solved here.

Thanks for explanation and fast answer.
Okay. Anything I can do to make this gameplay smooth, without “lag”,“jitter”,“motion blur” or anything else?

Again, those words are thrown around but they do not have an absolute meaning so no, I cannot give you a specific answer but I’m happy to try to figure out any inconsistent motion issues you might have and maybe figure out the source of them.

If inconsistent motion i.e it looks like it “stutters” then that can be caused by many things but it’s hard to just know without seeing if there’s something the profiler is showing like sudden garbage collection activity or something else. For sure, you’ll get this in the editor because the editor is doing all sorts of extra things that you won’t get in the player.

A big issue often encountered is when dealing with Update (per-frame) and FixedUpdate (default at 50Hz). There are many things here such as not using interpolation, directly driving the Transform, referring to the Transform position instead of the correct Rigidbody2D position etc. I don’t know the cause of your specific issue.

A big thing to figure out is if this is a camera-follow problem or not.

Just to add to the motion blur thing from before, here’s the difference between a screenshot and capturing on a camera where you can only see the “blur” on the camera:

Screenshot (no motion blur):

Camera (motion blur):

1 Like

As a separate post, it might be worth trying to isolate the issue in a separate new project by testing the same camera follow script to stationary objects and if that’s fine then test the same camera follow against moving objects. Obviously also turn-off the camera follow to ensure it’s nothing to do with that script not updating correctly.