@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:
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.
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.
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:
Use a stable Unity version (2018).
Create a new project and only add the few packages you really need to recreate the problem.
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?
@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 Recorded Video Session: 2D Platformer Character Controller - Unity Learn, 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
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));
}
}
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.
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.