Cinemachine with Pixel Art 2d Problem

Before I start, I’m sorry for my English.

Good morning, I have problems with the cinemachine and the perfect pixel, applied in a 16 pixel sprite video game.

My sprites are 16 px
I have done the rendering at 16 pixels

It works very well, if I leave no dead zone, damping or things like that, but when moving any configuration, my character starts an epileptic attack.

When I have everything to zero, I notice that the yellow dot of cinemachine jumps.

I think with the gif I will leave, it will be clearer what I say.

Thanks in advance with the help

emotionalanybass

It's really hard to tell what's going on without a repro project. Do you think you can send us one?

Hi Yuan, Of course, thank you very much for the help, I send you the project
Where do I upload it? Here it says it is too big, it weighs 35 Mb

I’ve uploaded it to dropbox, I don’t know if that’s how it works for you. Dropbox

Thanks! I’ve got the project. Will look into it later.

@yuanxing_cai Thank you for taking the time to look at my project, it really is very important to me, and I want to thank you in advance.

Because I am in a learning stage, and I feel frustrated that I cannot move forward. The development of Pixel Art video games is an important stage for native Indie developers (I don’t speak of small companies).

If Indie developers are an important market for Unity, they must go deeper into 2D Pixel Art, I mean take into account what is necessary for the development of pixel art and graphic projects 16, 32 and 64 pixel.

I have the same problem, I tried with cinemachine and without cinemachine, is there any idea, why do my sprites vibrate when I try to create the Lag effect of pixel art camera tracking? Why does Pixel Art have so many problems?

@Juandapp and @Lycc09 : I tried to reproduce the problem with the project from the dropbox link, but it seems to work fine:

halfcavernousarchaeopteryx

The only difference is, that I used Unity 2019.2.13f1 instead of 2019.3.0b11. I’m not sure, if this is the only difference, because I had some problems downgrading the project, so take this with a grain of salt.

Here some thoughts:

  1. I would recommend against using the latest Unity version. For testing new features and stuff, ok. But expect to run into problems. It sucks, because you then have to verify, if those problems exist in older versions.

  2. The PlayerMovement and CharacterController2D behaviours are messy. I don’t even know, why you separate the two scripts. Also store the rigidbody component in a local member variable.

  3. There are some things you should consider regarding rigidbody movement for 2D platformers. Shameless plug to a post of mine: https://www.zubspace.com/blog/smooth-movement-in-unity

  4. Is a Pixel-Perfect camera really required? I think that most people could not even tell the difference. Concentrate on proper movement and gameplay first. Then introduce a pixel-perfect camera option which can be enabled / disabled.

If you really need to get this working, I would proceed like this:

  1. Use a stable Unity version (2018).

  2. Create a new project and only add the few packages you really need to recreate the problem.

  3. Add a new script which does the bare minimum. No fancy stuff, just movement left and right. Add the pixel-perfect camera. Does the problem still occur?

  4. If nothing works, try to find similar code. Maybe on github or try to repro your problem with this asset: 2D Pixel Perfect Samples updated and moved to the 2D Pixel Perfect package in Package Manager (the samples can be imported if the package is installed) | Templates | Unity Asset Store . There are also other pixel-perfect camera assets on the asset store to try.

@ZuBsPaCe Your recommendation and tools in your article is impressive as I said. And I should thank you for spending the time on my problem, I am installing a stable version (LTS) to try again. The script I use is from Brackeys, unfortunately I am not advanced in C #, I am waiting for VisualScript from Unity, I come from Blueprint, however if Unity is complicated for 2D Pixel Art 16x16, Unreal Engine is slow death for 2D, That's why I decided now Unity, even with a line of code for now. With your article I have decided not to use physics for my game, and I will follow the following Unity tutorial to get to use kinematic https://learn.unity.com/tutorial/live-session-2d-platformer-character-controller, what do you think ?

Once I have finished configuring the Tutorial Script, I will put in practice that the rules of your article apply, and if it does not apply I will try to adapt the tutorial with your recommendations seen in your article.

When I have results I will return to close my doubt. (If they are positive) lol

Very very very thank you

I’ve got this same problem with the pixel perfect camera that the target sprite starts to jitter when i add any damping to my camera. There is no jitter if the camera is locked to the target without any damping or the camera is stationary when i move the sprite (tried with cinemachine cam and with my own cam setup). So when i activate pixel perfect camera without upscale or snapping on i can see this micro stutter/vibration in the movement and when enabling snapping or upscale it amplifies this effect.

I’ve tried lots of things such as moving the object with rigidbody by velocity and without rigidbody by translate, i’ve also check interpolate in rigidbody and made sure the movement happens in FixedUpdate, i’ve tried to mess with vsync and checked that my monitor refresh rates are all the same and tried to limit framerate to 60 and fiddle around nvidia 3d settings and tested in builds with exclusive fullscreen. I’ve also tested this with different unity versions and with the latest where the inconsistent Time.deltaTime is supposed to be fixed but no luck. Also note that i can almost eliminate the jitter by adding a specific amount of speed with like three decimal digits so i was thinking this might be tied to some refresh/framerate issue? I’m also not sure if its just the snapping from pixel perfect camera as my sprite is very tiny 16ppu but then again why the jitter happens only when i add damping to the camera?.

I’d be interested if anyone got any more ideas where this jitter might come from or is there some specific way i should apply smooth movement with pixelperfect camera or could this be hardware issue?

I tested the movement with these very simple scripts

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class movement3 : MonoBehaviour
{
        public float speed;
        private Rigidbody2D body;


    // Start is called before the first frame update
    void Start()
    {

        body = gameObject.GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
  
        body.velocity = new Vector2(h * speed, v * speed);
       
    }
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class movement2 : MonoBehaviour
{
        public float speed;

    void Update()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
  
        gameObject.transform.position = new Vector2 (transform.position.x + (h * speed),
        transform.position.y + (v * speed));
    }
}

shysecondcony

PLEASE I’m having this exact problem in 2022, was this ever resolved??

Yeah, same problem here too. It seems like pixel perfect does not work well with a follow camera (cinemachine transposer in my case). There is always some jittering on the main player that the camera follows when it moves.

Hi, i had same issue and i fixed it with setting my target object’s rigidbody2d interpolate settings none to interpolate.

So a different issue then. Understanding that a Rigidbody or Rigidbody2D like all of physics only updates during the FixedUpdate and not per-frame is important for sure. This is where interpolation comes in.

Lots of devs saying the “same problem” but with different root causes. This is an unfortunate consequence of threads being reused/necro’d like this.

Let’s close this thread, it’s run its course.

1 Like