As of now, 2D cameras tween and lerp using standard Vector2s with floats for the x and y values. This can lead to incorrect rendering in viewport-scaled (usually pixel-art) games when the x or y value of the camera's position ends in .5:
In order to solve this problem, I created a new bool property shown in the inspector called pixel_perfect.
In phantom_camera_host.gd, I added a check for the new property in both the _follow_pcam and _tween_pcam functions. If Pixel Perfect following is enabled, the x and y float values of the current point in the lerp or tween will be rounded to the nearest integer.
I also fixed a couple of small grammar mistakes in phantom_camera_2D.gd
The use case for this property is relatively obscure, but I hope it helps anyway!
Examples:
Before Pixel-Perfect following:
y value ends in .5x and y values both end in .5
After Pixel-Perfect following, the x and y values still both end in .5, but the camera host rounds each value to the nearest integer:
As of now, 2D cameras tween and lerp using standard Vector2s with floats for the x and y values. This can lead to incorrect rendering in viewport-scaled (usually pixel-art) games when the
x
ory
value of the camera's position ends in.5
:In order to solve this problem, I created a new
bool
property shown in the inspector calledpixel_perfect
.In
phantom_camera_host.gd
, I added a check for the new property in both the_follow_pcam
and_tween_pcam
functions. If Pixel Perfect following is enabled, thex
andy
float values of the current point in the lerp or tween will be rounded to the nearest integer. I also fixed a couple of small grammar mistakes inphantom_camera_2D.gd
The use case for this property is relatively obscure, but I hope it helps anyway!
Examples:
Before Pixel-Perfect following:
y
value ends in.5
x
andy
values both end in.5
After Pixel-Perfect following, the
x
andy
values still both end in.5
, but the camera host rounds each value to the nearest integer: