I uploaded a video to show the problem:http://youtu.be/8uswMQnmJJI
I have no physics used.
This is my camera follow code:
// Update is called once per frame
void LateUpdate () {
float player_x = targetToFollow.position.x;
float player_y = targetToFollow.position.y;
float rounded_x = RoundToNearestPixel(player_x);
float rounded_y = RoundToNearestPixel(player_y);
Vector3 new_pos = new Vector3(rounded_x, rounded_y, -10.0f); // this is 2d, so my camera is that far from the screen.
tr.position = new_pos;
// tr.position = new Vector3(targetToFollow.position.x, targetToFollow.position.y, -10f);
}
public float pixelToUnits = 100f;
public float RoundToNearestPixel(float unityUnits)
{
float valueInPixels = unityUnits * pixelToUnits;
valueInPixels = Mathf.Round(valueInPixels);
float roundedUnityUnits = valueInPixels * (1 / pixelToUnits);
return roundedUnityUnits;
}