-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
add viewport.get_camera_2d() #38317
add viewport.get_camera_2d() #38317
Conversation
Any progress with this PR? |
I assume that by now another rebase will be needed to merge. Will happily do so if a review passes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be rebased so it can be tested on latest master
first. The feature seems desired enough and was approved by reduz in the original issue, so it's probably good to merge if the code implementation is OK.
All fixed up. Just had to updated a few new instances of get_camera and a mention of it in the documentation. |
Ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the code and it looks fine, except one thing. set_current(false)
should check if this camera is really current, otherwise it will remove any current camera.
You can test this by creating two cameras, setting first to current and calling set_current(false)
on the second one. get_camera_2d()
will return null after this operation, while it should return the first camera.
Good catch! Fixed that. |
What is the status of this PR? It's been idle for a few months now but seems to be approved. |
This pull request needs to be rebased against the latest cc @verdog |
* there is now a more clear distinction between camera_2d and camera_3d functions in the engine code * simplified camera2d's exported interface - now everything happens directly with the 'current' variable and make_current and clear_current are no longer exposed- there were some situations where calling one instead of set_current would result in incomplete results * rebased to current godot master
Note that this is a breaking change, because it renames |
Since this targets 4.0, this is a good change, as it matches the rename of |
New to Godot. Thanks for clearing that up! |
Thanks! And sorry for the delay reviewing and merging this PR :) |
Is there a way to get_camera_2d() pre Godot 4? I kind of need to use this now. (I need to get the current camera position, so i can apply the current camera position to the "about to become active" camera position) |
For this feature to be available in Godot 3.5, this pull request needs to be remade against the |
Fixes #5411
First time contributor, still learning how things fit together, so I'd be happy to make any adjustments needed. 🙂
The
viewport.get_camera()
functionality already exists in 3d, so I just mimicked how 3d keeps track of things and added it to 2d. I added aCamera2D
pointer in the viewport class and it gets updated it as 2d cameras are set as current/turned off.Unlike 3d, in 2d, it is not required for a camera to be current. If this is the case,
get_camera_2d()
just returns null (just like what callingget_camera()
in 2d does).