- Home /
[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.
Disable Antialiasing in your project settings.
Edit > Project settings > Quality
It is disabled, I should have mentioned that.
Thanks for the reply
Answer by Mischa · Jan 06, 2016 at 09:56 AM
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.
The code updating the transform of the camera is in the player object, and the transform update code is located in FixedUpdate
Thanks for the reply
Answer by L_Artista · Jan 08, 2016 at 07:56 AM
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
The sprites all belong to specific sorting layers. Why would this cause flickering? And, is there a way to fix this without losing my layers?
Your answer
Follow this Question
Related Questions
2D Sprite leaves a trail when moving diagonally 1 Answer
2D Diablo style movement 1 Answer
SpriteManager 2 1 Answer
Many cameras with Camera.main.ScreenToWorldPoint trouble. 2 Answers