Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2D Follow Physics Interpolation #294

Merged
merged 19 commits into from
May 20, 2024
Merged

2D Follow Physics Interpolation #294

merged 19 commits into from
May 20, 2024

Conversation

ramokz
Copy link
Owner

@ramokz ramokz commented May 7, 2024

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 a follow target or follow targets (Group Follow).

For Godot 4.3

Project Settings

  • Enable the Physics Interpolation, inside physics/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

@ramokz ramokz marked this pull request as ready for review May 11, 2024 18:59
@ramokz ramokz changed the base branch from main to 0.7.1 May 11, 2024 19:13
@ramokz ramokz merged commit d49cf9c into 0.7.1 May 20, 2024
@ramokz ramokz deleted the physics-interpolation-2d branch May 20, 2024 11:13
ramokz added a commit that referenced this pull request Jun 1, 2024
* Move all spring arm initializaiton code out of _process into _ready (#282)

* Move all spring arm initializaiton code out of _process into _ready. Resolves #193

* Making _follow_spring_arm explicitly top_level

* Default _follow_spring_arm.position initialization to the original pcam position if follow_target is not available

* Updated plugin.cfg to 0.7.1

* Change Camera3DResource.cull_mask to use export_flags_3d_render. Resolves #290 (#293)

* Only show viewfinder if the active PCam's mode is framed (#295)

* Only show viewfinder in the correct follow mode

* Adjust comments

* Reorder early returns

* Remove unneeded type cast

* Updated Editor Updater wording for major releases

* Improved Limit Target error setter

* Added FUNDING.yml

* 2D Follow Physics Interpolation (#294)

* Initial _process / _physics_process logic split

* More 2d physics interpolation supported
- [Added] Interpolation Update Mode to PCamHost
- [Added] Additional warnings

* Commented out 4.3 specific code

* Stripped out a few todo comments

* Removed uneeded checkers

* Added physics body checker for Group Follow

* Added reset_physics_interpolation
- [Updated] Physics Interpolation to use string setters

* Added physics target checker to PCam3D
- [Moved] Follow Targets setters/getters closer to other Follow setters/getters

* Aligned PCam2D' script with PCam3D's

* Added missing variable assignment

* Added missing return for Framed Follow checker

* Removed unneeded boolean flag

* Tidied up process logic

* Added Jitter Tip output

* Added physics checker to Look At Group

* Updated parameter type from NodePath to Node3D

* Updated spacing for setters/getter functions

* Set _player_visual to top level in 2D example scene

* Added additional jitter context

* Updated append_look_at_targets_array

* Added Godot 4.3 2D example scene variants

---------

Co-authored-by: ZenithStar <ZenithStar@users.noreply.github.com>
Co-authored-by: audeck <55060124+audeck@users.noreply.github.com>
ramokz added a commit that referenced this pull request Jun 3, 2024
* Move all spring arm initializaiton code out of _process into _ready (#282)

* Move all spring arm initializaiton code out of _process into _ready. Resolves #193

* Making _follow_spring_arm explicitly top_level

* Default _follow_spring_arm.position initialization to the original pcam position if follow_target is not available

* Updated plugin.cfg to 0.7.1

* Change Camera3DResource.cull_mask to use export_flags_3d_render. Resolves #290 (#293)

* Only show viewfinder if the active PCam's mode is framed (#295)

* Only show viewfinder in the correct follow mode

* Adjust comments

* Reorder early returns

* Remove unneeded type cast

* Updated Editor Updater wording for major releases

* Improved Limit Target error setter

* Added FUNDING.yml

* 2D Follow Physics Interpolation (#294)

* Initial _process / _physics_process logic split

* More 2d physics interpolation supported
- [Added] Interpolation Update Mode to PCamHost
- [Added] Additional warnings

* Commented out 4.3 specific code

* Stripped out a few todo comments

* Removed uneeded checkers

* Added physics body checker for Group Follow

* Added reset_physics_interpolation
- [Updated] Physics Interpolation to use string setters

* Added physics target checker to PCam3D
- [Moved] Follow Targets setters/getters closer to other Follow setters/getters

* Aligned PCam2D' script with PCam3D's

* Added missing variable assignment

* Added missing return for Framed Follow checker

* Removed unneeded boolean flag

* Tidied up process logic

* Added Jitter Tip output

* Added physics checker to Look At Group

* Updated parameter type from NodePath to Node3D

* Updated spacing for setters/getter functions

* Set _player_visual to top level in 2D example scene

* Added additional jitter context

* Phantom Camera Manager (#306)

* Initial _process / _physics_process logic split

* More 2d physics interpolation supported
- [Added] Interpolation Update Mode to PCamHost
- [Added] Additional warnings

* Commented out 4.3 specific code

* Stripped out a few todo comments

* Removed uneeded checkers

* Added physics body checker for Group Follow

* Added reset_physics_interpolation
- [Updated] Physics Interpolation to use string setters

* Added physics target checker to PCam3D
- [Moved] Follow Targets setters/getters closer to other Follow setters/getters

* Aligned PCam2D' script with PCam3D's

* Added missing variable assignment

* Added missing return for Framed Follow checker

* Removed unneeded boolean flag

* Tidied up process logic

* Added Phantom Camera Manager singleton

* Minor fix for when not having a PCam in scene

* Removed print statement

* Fixed merge error

* Removed unneeded print statement

* Improved viewfinder detection (#307)

* Added PCamHost warning when not child of Camera

* Additional camera3d parameters (#308)

* Added additional PhantomCamera3DResource properties

* Shortened Camera3DResource local variable names

* Updated Editor Updater to be less intrusive (#309)

* Conditional checker for Cam3DRes changes

* Added support for disable_3d export templates (#311)

* Fixed viewfinder during play error

* Minor tweaks

* Minor post-main merge fix

* Updated plugin.cfg to 0.7.2

* Resolved issue with disabled tween on load for Third Person Follow (#319)

* Updated Third Person to update follow_position instead of global_position

* Removed commented out code in PCamHost

* Resolved issue with Follow Mode None getting stuck (#320)

* Added public properties and getters for PCamManager

* Updated git issue link

---------

Co-authored-by: ZenithStar <ZenithStar@users.noreply.github.com>
Co-authored-by: audeck <55060124+audeck@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant