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 in 2D that follows diagonal movements #372

Closed
lafitteque opened this issue Aug 26, 2024 · 6 comments
Closed

Framed Camera in 2D that follows diagonal movements #372

lafitteque opened this issue Aug 26, 2024 · 6 comments

Comments

@lafitteque
Copy link
Contributor

Project Type

2D

Feature Description

Currently, when you get to a border of the frame in Framed mode for a PhantomCamera2D, the position of the canvas relative to the player will not change while you stay on the porder of the frame. This can lead to weird situations like going on the bottom right corner of the frame and, once you get there, even if you go in the bottom left direction, the camera will not go to the left.

Without the feature :
https://github.com/user-attachments/assets/10bd431a-e135-4785-a0f9-9270ea021931

With the feature :
https://github.com/user-attachments/assets/c094f64b-b621-43a3-be26-d82b57601818

Use Cases

The idea of the framed camera is that it follows the player's movement. In the current version of this addon, the camera will not always follow the player's movent if on the borders of the frame.
The behaviour desribed is what I was looking for when I downloaded the addon. I think it is one of the main points of the framed camera.

(Optional) Proposed Solution

Replacing the condition at line 600 of res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_2d.gd by the following ones seems to work for me.

						elif _get_framed_side_offset().x != 0  and _get_framed_side_offset().y == 0:
							follow_position = target_position
							_follow_framed_offset.y = global_position.y - _target_position_with_offset().y
						elif _get_framed_side_offset().y != 0 and _get_framed_side_offset().x == 0 :
							follow_position = target_position
							_follow_framed_offset.x = global_position.x - _target_position_with_offset().x
						else : 
							follow_position = target_position
@ramokz
Copy link
Owner

ramokz commented Aug 27, 2024

There is an upcoming refactor task for Framed Follow in #161 that aims to solve things like this.

@ramokz
Copy link
Owner

ramokz commented Aug 27, 2024

Your proposal does seem to partly solve one of the main issues, so happy to add that in to alleviate the current approach until it can be fully looked at.

@ramokz
Copy link
Owner

ramokz commented Aug 27, 2024

Feel free to open a PR to add that small change in (if you want contribution credit); otherwise, I can add it in for the next release linking to this post.

lafitteque added a commit to lafitteque/phantom-camera that referenced this issue Aug 27, 2024
Actualizing _follow_framed_offset when on only one side of the frame.
@lafitteque
Copy link
Contributor Author

It's my first time making a PR so I hope I didn't mess up. In any case, if the PR is messed up, you can add it in for the next release like you said.

ramokz pushed a commit that referenced this issue Aug 27, 2024
Actualizing _follow_framed_offset when on only one side of the frame.
@ramokz
Copy link
Owner

ramokz commented Aug 27, 2024

It all looks great, so no need to worry 🙂

Thanks for sharing the improvement!

@ramokz
Copy link
Owner

ramokz commented Dec 9, 2024

Believe the PR solved the problem this issue described, so closing it.

If I misunderstood, please do let me know and can reopen this.

@ramokz ramokz closed this as completed Dec 9, 2024
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

3 participants
@ramokz @lafitteque and others