phantom-camera
phantom-camera copied to clipboard
2D Follow Physics Interpolation
[!IMPORTANT] Both Godot 4.2 and 4.3 are supported, however the enhancements here will only work for Godot 4.3 dev6 or later.
[!IMPORTANT] The changes only affect 2D scenes. 3D phyics interpolation are not yet supported in Godot and will be added in a future release.
What is this?
This change applies the newly added physics interpolation that was included in Godot 4.3 dev 6 release.
The changes in this PR allows a PCam2D
to support having a follow target
of either a PhysicsBody2D
-based or a non-PhysicsBody2D
-based node, where the Camera2D
will then automatically adjust its interpolation mode to match. Resulting in a jitter-free movement.
Before this, the user had to make use of either the smoothing-addon or implement their own solution to interpolate visuals as mentioned in the documentation.
For Godot 4.2
This release will still be compatible with Godot 4.2. It does a few checks to confirm the version and disables the added functionality while retaining existing behaviour. So nothing should be worse or better from this change.
[!NOTE] It will encourage to upgrade to Godot 4.3 if one attempts to select a
PhysicsBody2D
as afollow target
orfollow targets
(Group Follow).
For Godot 4.3
Project Settings
- Enable the
Physics Interpolation
, insidephysics/common/physics_interpolation
-
Advanced Settings
will likely need to be enabled to see it.
-
PhantomCameraHost
~~To enable the newly added physics interpolation, uncomment the following two lines inside PhantomCameraHost.gd
on line 201
and 206
.~~
camera_2d.physics_interpolation_mode = Node.PHYSICS_INTERPOLATION_MODE_ON
camera_2d.physics_interpolation_mode = Node.PHYSICS_INTERPOLATION_MODE_OFF
Do no uncomment those lines in Godot 4.2 as that will likely crash the editor.
Known Issues
[!NOTE] All known issues have now been addressed.
~~Switching to a PCam2D
that has a PhysicsBody2D
follow target
from another PCam2D
that either has no follow target
or a non-PhysicsBody2D
follow target
will cause a sudden camera flickering on the first few frames. The tween still triggers, but the effect is very noticeable and not good enough for release.~~
~~This appears to be due to setting the Camera2D
's physics_interpolation_mode
to Node.PHYSICS_INTERPOLATION_MODE_ON
from having previously being Node.PHYSICS_INTERPOLATION_MODE_OFF
.~~
Notes
- ~~This issue is only appearing when enabling it after it has been disabled, and not the other way around.~~
- ~~This appears to occur independently of the addon and occurs in simple projects too~~