[2D] Camera movement causes flickering/jittering sprites

Hi all, I did not initially plan on having camera movement in my project. But, now that I’m trying to implement it, I’m noticing a very problematic issue.

The camera object is not a child of any object, but instead it has this code telling it to follow the player object:

	void LateUpdate()
	{
		if(lockCamera == false)
			obj_cam.gameObject.transform.position = new Vector2(this.gameObject.transform.position.x, this.gameObject.transform.position.y);
	}

So, once the player begins to move I notice most, if not all, of the sprites begin to jitter/flicker.

Any help resolving this issue would be greatly appreciated, thank you.

Make sure to check if all sprites are in different sorting layer and/or have different order in layer that might be the reason for flickering!

https://unity3d.com/learn/tutorials/modules/beginner/2d/sorting-layers

Make sure that the update of the camera transform is always performed after the update of the object it should follow. You can achieve this by putting it in a LateUpdate.

As you have it in a LateUpdate in your code, my guess is that you either have the script on the camera itself and not on the gameObject it should follow or you update the transform of your followed gameObject in a LateUpdate too.