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

Framed camera will be stuck in offset if limit node target is set at runtime #209

Open
RichardStolp opened this issue Feb 4, 2024 · 2 comments

Comments

@RichardStolp
Copy link

Issue description

If the limit node target it set at runtime via the set_limit_node method and the Framed Phantom Camera 2D is not within the bounds of the limit node target then the camera will be stuck in an offset. The issue will stop if the player manages to push the camera into the limit boundary and reach the dead zone.

I ran into this issue when making prefabs for cameras and rooms.

The issue appears to be resolved when commenting out the line below in phantom_camera_2D.gd.

Properties.viewport_position = (get_follow_target_node().get_global_transform_with_canvas().get_origin() + Properties.follow_target_offset_2D) / get_viewport_rect().size

I don't fully understand the impact of this line yet so I didn't make a pr.

Framed_offset_issue.mp4
Framed_offest_working.mp4

Steps to reproduce

-Using the 2DLimitExampleScene, remove the Limit Node Target for RoomCentrePhantomCamera2D.
-Take the RoomCentrePhantomCamera2D and move it outside of RoomCentreArea2D's CollisionShape2D.
-Set the RoomCentrePhantomCamera2D's Limit Node Target in the _ready method of 2d_room_limit_tween.gd.

Phantom_framed_setup
room_limit_code_issue

(Optional) Minimal reproduction project

No response

@RichardStolp RichardStolp changed the title Framed camera will be stuck in offset if limit node target is st Framed camera will be stuck in offset if limit node target is set at runtime Feb 4, 2024
@RichardStolp
Copy link
Author

Found in version 0.6.3 of Phantom Camera and version 4.2.1 of Godot.

Could be related to issue 144

@ramokz
Copy link
Owner

ramokz commented Feb 5, 2024

Getting stuck outside the dead zones where the camera keeps following its target, however and whenever assigned, is a known issue and part of what is intended to be fixed in #161.

The first video is technically the more accurate one, as the second example always keeps the target in the middle of the camera when it's within the dead zone (e.g. at 0:05), which is not the intended result. At 0:08, in the first video, is what ought to happen.

The code you commented out is what detects the position of the target within the viewport. Without it, it will not keep the camera in place as you move around within the dead zone area. So it's definitely needed.

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

No branches or pull requests

2 participants