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:
- Computes the bounding box of every instance of the object (or group) passed in
- Centers the camera on the middle of that box
- Picks a zoom level that fits the whole box on screen, with your chosen padding
- 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:
- Create an object group containing everything the camera should keep in view (e.g. units, or a building + its target)
- Each frame, call
FrameCameraOnObjects(Objects, Layer, Padding, MinVisibleSize, Smoothing, MinZoom, MaxZoom)
- Tune
Padding and MinVisibleSize so the view doesn't feel too tight or too empty
- Tune
Smoothing for how quickly the camera catches up — higher is snappier, lower feels more floaty
- Set
MinZoom / MaxZoom as safety bounds so the camera never zooms in or out past what looks good in your game
Checklist
AI usage
Example file
DynamicCamera-Example.zip
Extension file
DynamicCamera.zip
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:
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
FrameCameraOnObjectsevery frame to keep a changing set of objects in view automatically, instead of a fixed camera on the whole level. Useful for:Setup:
FrameCameraOnObjects(Objects, Layer, Padding, MinVisibleSize, Smoothing, MinZoom, MaxZoom)PaddingandMinVisibleSizeso the view doesn't feel too tight or too emptySmoothingfor how quickly the camera catches up — higher is snappier, lower feels more floatyMinZoom/MaxZoomas safety bounds so the camera never zooms in or out past what looks good in your gameChecklist
AI usage
Example file
DynamicCamera-Example.zip
Extension file
DynamicCamera.zip