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

Fixed jitter for none physics object #179

Merged
merged 4 commits into from
Jan 19, 2024
Merged

Fixed jitter for none physics object #179

merged 4 commits into from
Jan 19, 2024

Conversation

P5ina
Copy link
Contributor

@P5ina P5ina commented Jan 17, 2024

Camera is not a physics body, it should be animated in _process. There is example of my fix:

Before

plugin_showcase.mp4

After

plugin_showcase_patch.mp4

The cube is animated through tweens, but they're working in _process. Script example:

extends MeshInstance3D

func _ready():
	var tween = create_tween().set_loops()
	tween.tween_property(self, "position", Vector3(4, 0, 0), 2.0).set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_QUAD)
	tween.tween_property(self, "position", Vector3(-4, 0, 0), 2.0).set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_QUAD)

@Lasuch69
Copy link

Hello! I want to point out that this change makes huge difference, however spring arm is still causing a bit of jitter when camera is up against the wall.

I am more than happy to implement spring arm smoothing once this PR is merged.

@P5ina
Copy link
Contributor Author

P5ina commented Jan 17, 2024

@Lasuch69 Thanks for pointing this out, I will investigate into this. I think I know how to fix this.

@ramokz
Copy link
Owner

ramokz commented Jan 18, 2024

This PR does seem to solve both your point of jittery animations happening in the _process, like your tween example, and the issue described in #173. Have been trying to find a way that meant you didn't need to use the smoothing-addon, but it might not be a feasible thing to automatically solve for this addon alone. Though there is still a jitter issue when you disable the damping and have a PhysicsBody a target. The obvious solution would be to use the visual representation (mesh/sprite) node as the Follow Target, but wonder if there's a way to still allow the PhysicsBody to be used as a target. Obviously, it's a fairly minor thing and won't lose any sleep over it.

This current solve does also mean that the requirement of the smoothing-addon needs to be communicated, especially to those just picking up the addon / Godot, as to not cause people to think something is fundamentally broken. Which is probably my biggest concern.

@ramokz ramokz linked an issue Jan 18, 2024 that may be closed by this pull request
@P5ina
Copy link
Contributor Author

P5ina commented Jan 18, 2024

@ramokz I think, we can make a switch to be able to use both _process and _physics_process. But I still think that using physics process for camera is a very bad idea and crutch but not a solution for physics objects.

@P5ina
Copy link
Contributor Author

P5ina commented Jan 18, 2024

I think I know how to fix this. We can make a smoothing inside the camera script, like it's done in smoothing addon. I'll implement this.

@Lasuch69
Copy link

Lasuch69 commented Jan 18, 2024

I don't think that we should care about if target is smoothed or not, as it isn't really the responsibility of the camera. If you want to fix jitter you need to smooth the target anyway. I would suggest making smoothing just for the spring arm and animation in the _process and that's all.

We would end up with double smoothing, which might introduce "lag".

Edit: Another way it could be done is to make camera smoothing optional.

@ramokz
Copy link
Owner

ramokz commented Jan 19, 2024

Inclined to agree that it's fair to expect the developer to be responsible for keeping visual representation of nodes smoothed when they're nested within a physics based node, given it's a known issue and should have a better built-in solution eventually. From reading, Godot 3.5 and 3.6 have 3D and 2D support respectively, so is just pending a 4.x integration. So happy to leave the PR in its current state and merge it in.

The one thing I do want to avoid is the experience friction point when people update the addon to then suddenly start seeing jitter that wasn't present before. For some, the solution would require them to add either an additional add-on, or add a few lines of code themselves — not a big deal in of itself, but will likely be confusing for people who don't know. For that reason, I would prefer this change being merged as part of the 0.7 release, as that will introduce wider breaking changes. So that will provide an opportunity to walk through everything that has changed and how to make a scene give the expected results in the release notes. Equally, docs and example scenes will also need to be updated as part of that.

@ramokz ramokz changed the base branch from main to 0.7 January 19, 2024 21:10
@ramokz ramokz merged commit 4d1f563 into ramokz:0.7 Jan 19, 2024
@ramokz
Copy link
Owner

ramokz commented Jan 19, 2024

Thanks for bringing up the discussion and submitting this PR 💯

ramokz added a commit that referenced this pull request Mar 20, 2024
* Update README.md

* Added a checker for PCam Host when a PCam exits the scene (#175)

* Fixed jitter for none physics object

---------

Co-authored-by: Marcus Skov <Hello@MarcusSkov.com>
ramokz added a commit that referenced this pull request Apr 25, 2024
* Added instance validator on _exit_tree()

* First pass for 3D _validate_property()

* Added additional 3D properties

* Fixed jitter for none physics object (#179)

* Update README.md

* Added a checker for PCam Host when a PCam exits the scene (#175)

* Fixed jitter for none physics object

---------

Co-authored-by: Marcus Skov <Hello@MarcusSkov.com>

* Updated CharacterControllers to support changed camera movement interpolation.

* Removed unneeded interpolation from phantom_camera_3D.gd

* Updated viewfinder.gd

* Minor property reference updates

* Updated phantom_camera_3D.gd and phantom_camera_2D.gd

* Updated plugin.cfg to 0.7

* Updated more properties and example scenes

* Fixed issue with grabbing active_pcam in viewfinder.gd

* Minor updates

* 171 third person quaternion (#190)

* Updated CharacterControllers to support changed camera movement interpolation.

* Removed unneeded interpolation from phantom_camera_3D.gd

* Added quaternion setter/getter for Third Person Follow

* Embedded enums to PCam3D script directly

* Added additional doc comments

* Updated 3D example scenes

* Merged #191 into 0.7

* (Re)added draw limits variable to PCam2D

* Updated script documentation

* Added more properties and signals to PCam scripts
- [Removed] Remaining constant. variable uses
- [Added] dead_zone_changed signal
- [Added] PhantomCameraHost variable to PCam scripts directly
- [Updated] viewfinder.gd with the dead_zone_changed signal change

- [Updated] pcam active setter in PCamHost using setter method

* Added enums directly to tween_resource.gd
- [Added] GDScript descriptions to tween resource properties

* Changed assign_pcam_host to set_pcam_host

* Updated .import files

* Readded Host to Third Person Example scene

* Updated example scenes

* Fixed issue with Limit Margin not updating correctly

* Updated Tween Resource enum names to align with Tween class

* Removed phantom_camera_properties.gd

* Swapped yaw and pitch variable names

* Removed group_names.gd
- [Moved] group_names.gd constants to phantom_camera_constants.gd

* Updated example scenes

* Added Cull Mask Helper Function
- [Added] Setter / Getter for SpringArm3D shape and margin
- [Renamed] Camera3DResource setter/getter names

* Changed reset_limit_all_sides() to reset_limit()

* Removed _camera_3D_resouce_default and tween_resource_default
- [Renamed] spring_arm setters/getters
- [Added] set_collision_mask_value helper function
- [Added] Missing setters/getters

* Fixed UI in 2D example scene

* Removed tween_resource_default from PCam2D

* Updated example scenes

* Fixed issue with limit not working after a tween

* Updated PCam Host setter/getter

* Privitised has_tweened and has_multiple_follow_targets

* Renamed pixel_perfect to snap_to_pixel

* Added look_at_target_changed signal

* Updated many script documentation comments

* Added missing default values to phantom_camera scripts

* Added comments and privatised variables and functions in phantom_camera_host.gd

* Added documentation and editor icon for tween_resource.gd

* Added documentation for camera_3D_resource.gd

* Fixed issue when assigning empty target(s) on editor start

* Updated editor icons and removed unused

* Viewfinder 2d (#220)

* Initial working 2D viewfinder

* Updated gizmo icon
- [Removed] Old Gizmo icon(s)
- [Updated] viewfinder_panel.tscn with improved icon sizing layout

* Improved 2D viewfinder
- [Renamed] Lowercased ...2D and ...3D to 2d/3d in various variable names

* Improved aspect ratio scaler

* Improved viewfinder logic checker

* Removed commented out logic

* CleanED up viewfinder file

- [Removed] editor_interface variables and replaced with singleton Class ref
- [Removed] Unneeded conditional checker and logic

* Simplified scene change signal function

* Solved error with viewfinder
 Now no longer being referenced from export builds

* Updated example scenes

* Added missing PCamHost to 2DExampleScene.tscn

* Fixed issue where various setters for _follow_spring_arm didn't get applied at runtime

* Added 2d rotation tween support

* Fixed issue with stacking viewfinder
Occured if you changed from one PCam to another that both used Framed Follow

* Cherry picked changes from main branch

* Added instance validator on _exit_tree()

* First pass for 3D _validate_property()

* Added additional 3D properties

* Fixed jitter for none physics object (#179)

* Update README.md

* Added a checker for PCam Host when a PCam exits the scene (#175)

* Fixed jitter for none physics object

---------

Co-authored-by: Marcus Skov <Hello@MarcusSkov.com>

* Updated viewfinder.gd

* Minor property reference updates

* Updated phantom_camera_3D.gd and phantom_camera_2D.gd

* Updated plugin.cfg to 0.7

* Updated more properties and example scenes

* Minor updates

* Updated CharacterControllers to support changed camera movement interpolation.

* Removed unneeded interpolation from phantom_camera_3D.gd

* 171 third person quaternion (#190)

* Updated CharacterControllers to support changed camera movement interpolation.

* Removed unneeded interpolation from phantom_camera_3D.gd

* Added quaternion setter/getter for Third Person Follow

* Embedded enums to PCam3D script directly

* Added additional doc comments

* Updated 3D example scenes

* Merged #191 into 0.7

* (Re)added draw limits variable to PCam2D

* Updated script documentation

* Added more properties and signals to PCam scripts
- [Removed] Remaining constant. variable uses
- [Added] dead_zone_changed signal
- [Added] PhantomCameraHost variable to PCam scripts directly
- [Updated] viewfinder.gd with the dead_zone_changed signal change

- [Updated] pcam active setter in PCamHost using setter method

* Added enums directly to tween_resource.gd
- [Added] GDScript descriptions to tween resource properties

* Changed assign_pcam_host to set_pcam_host

* Readded Host to Third Person Example scene

* Updated example scenes

* Fixed issue with Limit Margin not updating correctly

* Updated Tween Resource enum names to align with Tween class

* Removed phantom_camera_properties.gd

* Swapped yaw and pitch variable names

* Removed group_names.gd
- [Moved] group_names.gd constants to phantom_camera_constants.gd

* Updated example scenes

* Added Cull Mask Helper Function
- [Added] Setter / Getter for SpringArm3D shape and margin
- [Renamed] Camera3DResource setter/getter names

* Changed reset_limit_all_sides() to reset_limit()

* Removed _camera_3D_resouce_default and tween_resource_default
- [Renamed] spring_arm setters/getters
- [Added] set_collision_mask_value helper function
- [Added] Missing setters/getters

* Fixed UI in 2D example scene

* Removed tween_resource_default from PCam2D

* Updated example scenes

* Fixed issue with limit not working after a tween

* Updated PCam Host setter/getter

* Privitised has_tweened and has_multiple_follow_targets

* Renamed pixel_perfect to snap_to_pixel

* Added look_at_target_changed signal

* Updated many script documentation comments

* Added missing default values to phantom_camera scripts

* Added comments and privatised variables and functions in phantom_camera_host.gd

* Added documentation and editor icon for tween_resource.gd

* Added documentation for camera_3D_resource.gd

* Fixed issue when assigning empty target(s) on editor start

* Updated editor icons and removed unused

* Viewfinder 2d (#220)

* Initial working 2D viewfinder

* Updated gizmo icon
- [Removed] Old Gizmo icon(s)
- [Updated] viewfinder_panel.tscn with improved icon sizing layout

* Improved 2D viewfinder
- [Renamed] Lowercased ...2D and ...3D to 2d/3d in various variable names

* Improved aspect ratio scaler

* Improved viewfinder logic checker

* Removed commented out logic

* CleanED up viewfinder file

- [Removed] editor_interface variables and replaced with singleton Class ref
- [Removed] Unneeded conditional checker and logic

* Simplified scene change signal function

* Solved error with viewfinder
 Now no longer being referenced from export builds

* Updated example scenes

* Added missing PCamHost to 2DExampleScene.tscn

* Fixed issue where various setters for _follow_spring_arm didn't get applied at runtime

* Added 2d rotation tween support

* Fixed issue with stacking viewfinder
Occured if you changed from one PCam to another that both used Framed Follow

* Cherry picked changes from main branch

* Damping 2.0 (#248)

* Smooth damp for phantom_camera_3D.gd

* Minor 3D damping updates

* Added Smooth Damp to phantom_camera_2D.gd
- [Updated] Minor things for 3D smooth damp system

* Re-added physics interpolation to 2D script

* Removed Smoothing nodes and improved 2d documentation

* Rotate damping (#251)

* Fixed incorrect name and added type to variable

* Fixed issue with look_at method not being called

* Added Look At Damping properties

* Changed _set_velocity to _set_follow_velocity

* Added Look At damping

* Updated damping default values

* Added conditional look_at_damping

* Added damping to LookAt Group

* Minor property updater fixes

* Removed unneeded variable

* Added range slider to Look At Damping

* Added additional look_at checks

* smooth_damp function parameter alignment

* Minor Group Look At fix

* Removed unused variables

* Corrected fixed camera angle tween duration

* Fixed issue with tweening 2D zoom

* Made player model be set to top level

* Made playable_character_2d.tscn its own scene

* Updated default 2D follow_damping_value

* Added playable_character_3d

* Updated remaining example scenes and scripts

* Updated room limit script

* Updated dev_scene_3d

* Renamed 2d_trigger_area

* Fixed tween issue in 3DExampleScene.tscn

* Removed documentation comment from _is_active

* Updated tween_onload to tween_on_load

* Updated examples scenes with tween_on_load rename

* Minor CharacterController changes

* Whitespace removal

* Renamed core scripts
[Renamed] phantom_camera_2D.gd to phantom_camera_2d.gd
[Renamed] phantom_camera_3D.gd to phantom_camera_3d.gd

* Renamed camera_3D_resource
- [Renamed] Renamed camera_3D_resource to camera_3d_resource.gd

* Renamed UpdateButton.tscn
- [Renamed] UpdateButton.tscn to update_button.tscn

* Renamed phantom_camera_gizmo_plugin_3D.gd
- [Renamed] phantom_camera_gizmo_plugin_3D.gd to phantom_camera_gizmo_plugin_3d.gd

* Renamed CustomGizmo.gd
- [Renamed] CustomGizmo.gd to custom_gizmo.gd

* Renamed example scenes to use snake_case

* Renamed image assets and remaining scenes

---------

Co-authored-by: Timur Turatbekov <44378225+P5ina@users.noreply.github.com>
Co-authored-by: ZenithStar <zenithstar@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.

Jittery camera movement
3 participants