Skip to content

Handle non-rectangle rooms for camera limits #94

@DarkRewar

Description

@DarkRewar

Problem

Currently, the camera limits are set based on the global room size, using min/max positions. This method works for rectangular rooms but not for "freeform".

The method is called in RoomInstance::adjust_camera_limits:

## Adjusts the limits of the given [param camera] to be within this room's rectangular bounds.
func adjust_camera_limits(camera: Camera2D):
	camera.limit_left = 0
	camera.limit_top = 0
	camera.limit_right = get_size().x
	camera.limit_bottom = get_size().y

The following screenshots show how a "L-shape" room applies the camera limits in game :

The room layout:
Image

The room tilemap:
Image

In-game visibility, the camera is correctly confined on the min/max borders, but the camera displays a
Image

Possible solution?

Don't use the native Camera2D::limit_[side] and use a dolly system based on CollisionPolygon2D component? Could be generated on the room_init and confines the camera inside the polygon shape.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions