Skip to content

New extension: Dynamic Camera #2284

Description

@NicolasDemangeat

Description

Adds a FrameCameraOnObjects action that moves and zooms a camera so every instance of a given object or group stays inside the view, with padding, a minimum visible size, and smooth interpolation toward the target.

Each call:

  1. Computes the bounding box of every instance of the object (or group) passed in
  2. Centers the camera on the middle of that box
  3. Picks a zoom level that fits the whole box on screen, with your chosen padding
  4. Smoothly interpolates the camera's position and zoom toward that target, instead of snapping instantly

No JavaScript involved, the whole extension is built with regular GDevelop events, so it's easy to inspect, tweak, or extend.

How to use the extension

Call FrameCameraOnObjects every frame to keep a changing set of objects in view automatically, instead of a fixed camera on the whole level. Useful for:

  • A construction or crafting game where the camera should follow the current build
  • A strategy game following a group of selected units
  • Any scene where the important area shrinks or grows over time

Setup:

  1. Create an object group containing everything the camera should keep in view (e.g. units, or a building + its target)
  2. Each frame, call FrameCameraOnObjects(Objects, Layer, Padding, MinVisibleSize, Smoothing, MinZoom, MaxZoom)
  3. Tune Padding and MinVisibleSize so the view doesn't feel too tight or too empty
  4. Tune Smoothing for how quickly the camera catches up — higher is snappier, lower feels more floaty
  5. Set MinZoom / MaxZoom as safety bounds so the camera never zooms in or out past what looks good in your game

Checklist

  • I've followed all of the best practices.
  • I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
  • I am aware that the extension may be updated by anyone, and do not need my explicit consent to do so.

AI usage

  • I used an AI to generate some part of the code.
  • I don't understand the generated code or I don't feel able to modify it.

Example file

DynamicCamera-Example.zip

Extension file

DynamicCamera.zip

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions