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

Configurable camera minimum/maximum per scene #1698

Open
GideonZhi opened this issue Feb 21, 2025 · 1 comment
Open

Configurable camera minimum/maximum per scene #1698

GideonZhi opened this issue Feb 21, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@GideonZhi
Copy link

GideonZhi commented Feb 21, 2025

Is your feature request related to a problem? Please describe.
I'm working on a platformer, and I find it helpful to have "off-stage" areas in each scene in which to stage actors for walking on, so they don't just appear at the edge of the scene, or to allow the player to actually walk off the edge of the scene for a transition trigger without having the transition happen when they hit the edge of the scene. Like this:

Image

Unfortunately there doesn't appear to be any way to set minimum and maximum values for the camera inside the GB Studio engine without either lots of enormous triggers, an invisible camera controller actor that manages the camera position in its update script, or ejecting the engine.

Describe the solution you'd like
I'd propose adding an event that can be added to the scene's On Init script that would allow the user to set minimum and maximum values for the camera's X and Y coordinates, at the pixel or tile level. I've accomplished this in my game by using an engine eject and editing camera.c as follows:

#define CAMERA_MIN_X 1792
#define CAMERA_MIN_Y 1664
#define CAMERA_MAX_X 3328
#define CAMERA_MAX_Y 1664

...
void camera_update(void) NONBANKED {
...

    // Clamp X
    if (camera_x < CAMERA_MIN_X) {
        camera_x = CAMERA_MIN_X;
    } else if (camera_x > CAMERA_MAX_X) {
        camera_x = CAMERA_MAX_X;
    }

    // Clamp Y
    if (camera_y < CAMERA_MIN_Y) {
        camera_y = CAMERA_MIN_Y;
    } else if (camera_y > CAMERA_MAX_Y) {
        camera_y = CAMERA_MAX_Y;
    }
}

But this only really works for me because my scenes are all uniform in size (32 tiles wide and 18 tiles tall, plus four on each of the four sides, for a total of 40x26 tiles.)

Describe alternatives you've considered
I've tried accomplishing this with triggers to move the camera to scene edge when the player gets close, then lock it back to the player then the player moves away, but there are problems with this:

  • The triggers necessary would need to be quite large in the scene, and their sizes would need to change if the developer ever adjusted the camera deadzone.
  • The Camera Move To event is not aligned onto the same pixel when the player moves into the trigger, so it sort of jitters a bit as it locks if speed is set to Instant.
  • Camera Lock To Player only lets you lock one axis, not both.

I've also tried this with an invisible actor whose On Update script sets the camera position if the player enters a particular range in the scene, but this generates a fair bit of lag.

@GideonZhi GideonZhi added the enhancement New feature or request label Feb 21, 2025
@maxoakland
Copy link

Yes! This would be a great feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants