Sprites around my player is shaking when the player is moving

All of my sprites are 32x32 pixels. A
camera is following my player and
everytime my player is moving, the
other sprites that are seen in the
camera are shaking/shuddering. When my
player is moving up, the sprites are
shaking up and down.

I already have all my shaders pixel
snapped. I’ve also tried it without
pixel snapping. I also tried making my
sprites Bilinnear, Trillinear, and
Point, and none of those three fixed
the problem.

I’m also not using a code for my
camera to follow the player. I just
have my player as the parent of the
camera, so the player is always pixel
perfect even when I’m moving since I’m
always at the center, but the other
sprites around me are shuddering.

My player moves with
rigidbody.velocity. And it works just
fine with my player. EDIT: My player
moves with rigidbody2D.velocity.

edit/additional info: The shaking only
appears on the sprites that are not
moving. The other sprites around me
(the non-player sprites) have a code
that makes them move by themselves.
Whether the player/camera is moving or
not, the sprites who are moving with
rigidbody.velocity (the same as my
player’s) doesn’t shake or jitter.

I’ve googled EVERYWHERE about my
problem, and NONE worked so far. The
sprites around the player just keeps
jittering when the player/camera is

Please help. My boss is going to fire
me and murder me afterwards for
wasting his time. I hope I explained
everything clearly. Thanks! :slight_smile:


I tried to use this function:

	public static float RoundToNearestPixel(float unityUnits,

Camera viewingCamera)
float valueInPixels = (Screen.height /
(viewingCamera.orthographicSize * 2))

  • unityUnits;
    valueInPixels = Mathf.Round(valueInPixels);
    float adjustedUnityUnits = valueInPixels / (Screen.height /
    (viewingCamera.orthographicSize * 2));
    return adjustedUnityUnits;

With this code in the Update()

	Vector3 roundPos = new Vector3(RoundToNearestPixel(p.transform.position.x,

transform.position = roundPos;

And the sprites around me stopped
shaking! BUT then, it was my player
now that started shaking. Everytime I
move, my player started to shake just
like how the other npcs around me
shaked without that code above. How
can I fix this? I want all sprites to
stop shaking when I’m moving.

And yeah, I think I know why it’s
shaking, because I know how the code
above works. It’s just that I don’t
know how to fix it.

NEW EDIT/UPDATE: I somehow made the
shaking of my player less visible by
having its shader pixel-snapped. But
it’s still there. And when I’m moving
left or right, there are black lines
that appear and disappear at the end
of his face. So his face grows longer
in width with that black line and goes
back to original everytime I move.

So yeah, it’s clearly less visible
when I pixel snap it, but it’s still

Thanks :)*


Nevermind guys. My employer just randomly decided to find another programmer. (In other words, he fired me.) So I guess I won’t need an answer for this problem anymore. But still, thanks for all your time and help! :slight_smile:

Try to avoid using RigidBody with sprites, use RigidBody2D instead.

As for the movement, remove the RigidBody and try this

private float hor, ver;
public float speed = 1;

void Update () {
   hor = Input.GetAxisRaw("Horizontal");
   ver = Input.GetAxisRaw("Vertical");

   transform.Translate((hor * Vector2.right + ver * Vector2.up ) * Time.deltaTime * speed);

It works well for me at least.

As a side note, you should be careful, if you are using plain sprites in a solid color background, you will notice the jittering a lot, specially if you are moving in the X axis. This is normal the way the refresh of the screen works, if you want to solve this, you should configure the V-Sync in the quality settings to your needs.

I get the feeling this is happening because you’re affecting Physics objects, and you’re using Update(). If you do anything at all with RigidBody, Collider or other physics components, you must do that in FixedUpdate(). Additionally, switch any multiplication with Time.deltaTime to use Time.fixedDeltaTime for any code you move to FixedUpdate().

Hopefully, your jittering will be gone :slight_smile: I think the camera / player parenting is a red herring.

PS - FixedUpdate() is generally going to be better than LateUpdate(), when it comes to modifying Physics components. Physics processing for the current frame is already finished when LateUpdate() is called, so any changes you make to physics objects within LateUpdate() won’t apply until the next frame - because no further processing will be applied to them by the physics engine.


This page in the Unity docs explains the per-frame events/timeline, and there’s a diagram at the bottom that shows the whole thing - damn useful :slight_smile: