Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cinemachine with Pixel Art 2d Problem

Discussion in '2D' started by Juandapp, Nov 14, 2019.

Thread Status:
Not open for further replies.
  1. Juandapp

    Juandapp

    Joined:
    May 11, 2016
    Posts:
    53
    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


     
  2. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    It's really hard to tell what's going on without a repro project. Do you think you can send us one?
     
  3. Juandapp

    Juandapp

    Joined:
    May 11, 2016
    Posts:
    53
    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
     
  4. Juandapp

    Juandapp

    Joined:
    May 11, 2016
    Posts:
    53
  5. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
  6. Juandapp

    Juandapp

    Joined:
    May 11, 2016
    Posts:
    53
    @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.
     
  7. Lycc09

    Lycc09

    Joined:
    Nov 21, 2019
    Posts:
    1
    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?
     
  8. ZuBsPaCe

    ZuBsPaCe

    Joined:
    Oct 14, 2014
    Posts:
    5
    @Juandapp and @Lycc09: I tried to reproduce the problem with the project from the dropbox link, but it seems to work fine:



    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: https://bit.ly/37xEMS3 . There are also other pixel-perfect camera assets on the asset store to try.
     
    Last edited: Nov 23, 2019
  9. Juandapp

    Juandapp

    Joined:
    May 11, 2016
    Posts:
    53
    @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
     
  10. Coin9

    Coin9

    Joined:
    Feb 14, 2019
    Posts:
    16
    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

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class movement3 : MonoBehaviour
    6. {
    7.         public float speed;
    8.         private Rigidbody2D body;
    9.  
    10.  
    11.     // Start is called before the first frame update
    12.     void Start()
    13.     {
    14.  
    15.         body = gameObject.GetComponent<Rigidbody2D>();
    16.     }
    17.  
    18.     // Update is called once per frame
    19.     void FixedUpdate()
    20.     {
    21.         float h = Input.GetAxis("Horizontal");
    22.         float v = Input.GetAxis("Vertical");
    23.  
    24.         body.velocity = new Vector2(h * speed, v * speed);
    25.        
    26.     }
    27. }
    28.  
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class movement2 : MonoBehaviour
    6. {
    7.         public float speed;
    8.  
    9.     void Update()
    10.     {
    11.         float h = Input.GetAxis("Horizontal");
    12.         float v = Input.GetAxis("Vertical");
    13.  
    14.         gameObject.transform.position = new Vector2 (transform.position.x + (h * speed),
    15.         transform.position.y + (v * speed));
    16.     }
    17. }
     
  11. Isodor

    Isodor

    Joined:
    Nov 30, 2020
    Posts:
    1
    PLEASE I'm having this exact problem in 2022, was this ever resolved??
     
  12. IMmoRTalis_93

    IMmoRTalis_93

    Joined:
    Aug 16, 2015
    Posts:
    1
    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.
     
  13. ErtugrulSngr

    ErtugrulSngr

    Joined:
    Oct 28, 2020
    Posts:
    1
    Hi, i had same issue and i fixed it with setting my target object's rigidbody2d interpolate settings none to interpolate.
     
  14. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    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.
     
    Kurt-Dekker likes this.
Thread Status:
Not open for further replies.