- Home /
2d sprite flickering on iPhone 6 but not iPad
Hello,
I'm working on a 2d game for iOS. The sprites I use are imported with FilterMode: point and Format: truecolor, vSync is off in the quality settings. I'm putting the camera position in Update on rounded pixels and still on iPhone 6 I get a little flickering on the edges of the sprites. For example when the camera moves, some vertical lines switch between a width of 2px and 1px very fast. Putting the camera on rounded positions helped on my iPad 2 but not on my iPhone 6.
I use a script to set the camera size like this:
int height = Mathf.RoundToInt(targetWidth / (float)Screen.width * Screen.height);
GetComponent<Camera>().orthographicSize = height / pixelsToUnits;
And here is how I put the camera on rounded pixel positions (it follows the character):
private void updateCam(){
float newX = RoundToNearestPixel (transform.position.x, 100);
float newY = RoundToNearestPixel (transform.position.y, 100);
Camera.main.transform.position = new Vector3 (newX + 6, newY, -15);
}
public float RoundToNearestPixel(float unityUnits, float pixelToUnits)
{
float valueInPixels = unityUnits * pixelToUnits;
valueInPixels = Mathf.Round(valueInPixels);
float roundedUnityUnits = valueInPixels * (1 / pixelToUnits);
return roundedUnityUnits;
}
Any ideas why it's still flickering? I'm working with Unity 5.2, xCode 7.1 beta and iOS 9.
Thanks! Stefan
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612040419im_/https://answers.unity.com/themes/thub/images/avi.jpg)