Skip to content

Camera2D get_camera_screen_center() reports bad position with rotating camera #44358

@DragonAxe

Description

@DragonAxe

Godot version:
Godot Engine v3.2.3.stable.official

OS/device including version:
Arch Linux 5.9.11-arch2-1 #1 SMP PREEMPT Sat, 28 Nov 2020 02:07:22 +0000 x86_64 GNU/Linux
OpenGL ES 3.0 Renderer: Mesa Intel(R) UHD Graphics 620 (KBL GT2)

Issue description:
What happened: Camera2D method get_camera_screen_center() does not return (0, 0) when the camera is being rotated with self.rotate(0.1*delta), Offset=(0, 0), Current=On, Rotating=On, and Anchor Mode = Drag Center.
Note: With Anchor Mode = Fixed TopLeft I also see unexpected behavior where the position reported by get_camera_screen_center() remains unchanged even though the camera view is rotating about the top left corner.

What I expected: get_camera_screen_center() should continue to return (0, 0) at any rotation angle as long as Offset=(0, 0) and the Anchor Mode = Drag Center.
Note: With Anchor Mode = Fixed TopLeft the position reported by get_camera_screen_center() should follow a circular path with center at the top left corner of the camera and radius equal to half the diagonal length of the camera window size.

https://docs.godotengine.org/en/stable/classes/class_camera2d.html#class-camera2d-method-get-camera-screen-center

Steps to reproduce:

  • Create a new 2d scene.
  • Create a Camera2D as a child node of the scene root.
  • Create a Label as a child node of the scene root. (The label is simply for displaying the result of get_camera_screen_center().)
  • Set the following Camera2D settings:
    Anchor Mode: Drag Center
    Rotating: On
    Current: On
  • Attach the following script to the Camera2D node.
extends Camera2D

func _ready():
	set_process(true)

func _process(delta):
	self.rotate(0.1*delta)
	$"../Label".text = str(self.get_camera_screen_center())
  • Run.
    You should see the label in the center of the screen rotating while displaying the output of get_camera_screen_center().

Minimal reproduction project:
bug_cam_screen_center.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions