Hello everyone,
I’m currently working on a 2D game in Unity and I’ve been facing issue with my background appearing jittery during player movement. I’m using a Rigidbody2D for the player, Pixel perfect component for the camera and a Cinemachine camera to follow the player. However, despite my efforts to achieve smooth movement, the background become noticeably jittery when the player moves. Here is more information:
- My rigidbody interpolation is set to interpolate.
- My pixel perfect camera ppu is 32 same as my sprites ppu
- My game resoultion is 1920x1080 so i use 470x280 refrnece resoultion
- Im using defualt cinemachine brain settings and no damping on my virtual camera
- Im using the cinemachine pixel perfect extension but its not seem to do anything
- This is how i move my player:
public class Player : MonoBehaviour
{
public float moveSpeed = 5f;
Rigidbody2D rb;
Animator anim;
Vector2 movement;
private void Awake()
{
rb = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
}
void OnMovement(InputValue value)
{
movement = value.Get<Vector2>();
}
private void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
}
}
I tryed to solve this issue for so long but nothing appear to help i would realy appreciate if someone will help me fix this problem thanks.
Why this reference resolution? You need to pick a reference resolution that divides evenly to your screen/viewport resolution. 470 x 280 doesn’t do that. It’s not even a remotely standard resolution!
You ought to pick a reference resolution that divides evenly across as many standard resolutions as you care to support. I’m using 640 x 360 in a current project as it supports all the main resolutions. If you need a chunkier style, you can go half that.
1 Like
Hey thanks for your respond, i tryed using 320x180 refrence resoultion but it didnt solve the jittery background
I done everything they said in there and the background is still jittery
Can you make a video of that? Maybe it’s just low framerate. Or you mean something else, like aliasing, which may happen if you move a scaled image.
Yes i can make a video of that, in the editor my game is running at 500fps+ and i disabled anti aliasing.
How i upload a video to the unity formus? or do you have discord and i can upload there.
You said in another thread that you’ve been struggling with this for weeks but the very first thing you should do is isolate things to try to narrow down what’s going on. The obvious first thing is to not use a Rigidbody2D but instead remove it and just set the Transform for movement per-frame instead.
If it still does it then you’ve discounted something you’re doing with physics. Stuff like this.
You should be using source control too so you can hack away at your project, reducing it until you find the issue and when you do you can restore the project and fix the problem.
Hey thanks for your respond i tryed moving without physics just moving the transform but nothing was differnce i asked in a lot of discord servers and done every part right if its how i move my player with rigidbody or the cinemachine settings or pixel perfect component values and it still jittery could it be something with any settings in the project settings or my computer?
You can’t. You have to upload it somewhere else (Google Drive, Youtube, Vimeo, etc) and paste the URL here.
Do you have discord so i can show you it in there?