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

Camera2D drag margin position issues #20142

Closed
jeffrimko opened this issue Jul 13, 2018 · 1 comment
Closed

Camera2D drag margin position issues #20142

jeffrimko opened this issue Jul 13, 2018 · 1 comment

Comments

@jeffrimko
Copy link

Godot version:
v3.0.4 stable

OS/device including version:
Windows 10

Issue description:
Camera2D drag margins do not appear to respect position/offset when game is running. Strangely, the margins look correct in the editor but they do not correspond to the margins used when the game is running.

This might be related to issue #7489.

Steps to reproduce:
In the linked demo project, the game world has a simple camera looking at a player that can move up/down/left/right. There are blocks showing where the default drag margins are located. When the camera is offset, the drag margins are not respected when the game runs. I have tried using the "Camera2D -> Offset" and the "Camera2D -> Transform -> Position" values but both behave the same. For example:

  • Change "Camera2D -> Transform -> Position" to (50, 0).
  • Notice that the drag margins in the editor have updated to show the new offset position.
  • Run the game and move the player to the left.
  • Notice that the camera does not respect the new drag margin location since the camera should move almost as soon as the player moves.

Minimal reproduction project:
201807131809-camera2d_margin_issue_demo.zip

@bojidar-bg
Copy link
Contributor

I feel this might be a misunderstanding. The Camera2D node does not try to keep its parent node's position inside the drag margins, but its own position. It starts centered when the game is run, so it needs to move at least a drag margin away before it starts moving.

The wanted effect can be accomplished by moving the camera after it manages to initialize itself.
For example something like this might work:

func _ready():
	$Camera2D.force_update_scroll()
	$Camera2D.position = Vector2(0, 0)

That way, the camera would start with displaced drag margins, moving it back to (0, 0) would ensure it is centered on the player.

Going to close this issue as I don't think it is a bug. If it actually turns out to be one, it might be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants