I have different characters on a topdown game. When I click on a character, their information is shown in a UI window. I’d like to show a 2nd camera (different from the main camera) that is zoomed in and focused on that character, in the UI.
I’m checking the subviewport but couldn’t figure out a way yet.
You need to use SubViewports indeed. Here’s my little demo:
This is the setup I made in my Player scene. The SecondCameraOffset is just the Node3D, where I want the Camera3D to be and then I just teleport the camera to that place on every frame. This is because anything inside the SubViewport has its transform reset, because a SubViewport doesn’t extend from Node3D, so the transform is lost.
that did not work for me. I wonder if there is more setting needed or maybe related to 2D cameras?
In process, that’s what I added: camera.global_position = camera_offset.global_position
Oh, I didn’t realize you’re working with 2D, sorry.
For 2D, you need to assign the World2D from your main scene to your SubViewport. Something like that in the SubViewport script should do the trick.