Index of every page on this site: llms.txt
All skills
jame581 avatar

/camera-system

@426e8ab
by Jan Mesarčjame581/godotprompter979 stars
63
Run it yourself

Use when implementing cameras — smooth follow, screen shake, camera zones, and transitions for 2D and 3D

Use this Skill: https://skilld.dev/gh/jame581/godotprompter/camera-system

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencescamera-zones.md

≈877 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Camera Zones / Rooms

Reference for skills/camera-system/SKILL.md — Area2D-based room cameras with limit tweens, GDScript + C#.

← Back to SKILL.md


4. Camera Zones / Rooms

For Metroidvania or Zelda-style games, Area2D regions define camera bounds per room. When the player enters a zone, the camera limits tween smoothly to the new room boundaries.

GDScript

CameraZone node — place one per room, sized to fit the room:

## CameraZone.gd — attach to an Area2D
## Set collision layer so only the player can trigger it.
extends Area2D

## Room bounds in world pixels (set via CollisionShape2D or exported values)
@export var limit_left: int = 0
@export var limit_right: int = 320
@export var limit_top: int = 0
@export var limit_bottom: int = 180

## Seconds to tween the camera limits when entering this room
@export var transition_time: float = 0.4

func _ready() -> void:
    body_entered.connect(_on_body_entered)

func _on_body_entered(body: Node2D) -> void:
    # Only react to the player (adjust group name to match your project)
    if not body.is_in_group("player"):
        return

    var cam := body.get_viewport().get_camera_2d()
    if not cam:
        return

    var tween: Tween = create_tween()
    tween.set_parallel(true)
    tween.set_ease(Tween.EASE_IN_OUT)
    tween.set_trans(Tween.TRANS_SINE)

    tween.tween_property(cam, "limit_left",   limit_left,   transition_time)
    tween.tween_property(cam, "limit_right",  limit_right,  transition_time)
    tween.tween_property(cam, "limit_top",    limit_top,    transition_time)
    tween.tween_property(cam, "limit_bottom", limit_bottom, transition_time)

C#

// CameraZone.cs — attach to an Area2D
using Godot;

public partial class CameraZone : Area2D
{
    [Export] public int LimitLeft   { get; set; } = 0;
    [Export] public int LimitRight  { get; set; } = 320;
    [Export] public int LimitTop    { get; set; } = 0;
    [Export] public int LimitBottom { get; set; } = 180;
    [Export] public float TransitionTime { get; set; } = 0.4f;

    public override void _Ready()
    {
        BodyEntered += OnBodyEntered;
    }

    private void OnBodyEntered(Node2D body)
    {
        if (!body.IsInGroup("player")) return;
        var cam = body.GetViewport().GetCamera2D();
        if (cam == null) return;

        var tween = CreateTween();
        tween.SetParallel(true);
        tween.SetEase(Tween.EaseType.InOut);
        tween.SetTrans(Tween.TransitionType.Sine);

        tween.TweenProperty(cam, "limit_left",   LimitLeft,   TransitionTime);
        tween.TweenProperty(cam, "limit_right",  LimitRight,  TransitionTime);
        tween.TweenProperty(cam, "limit_top",    LimitTop,    TransitionTime);
        tween.TweenProperty(cam, "limit_bottom", LimitBottom, TransitionTime);
    }
}

Scene setup:

World
├── TileMapLayer
├── Player (CharacterBody2D) — group: "player"
├── Camera2D          ← child of Player or a separate autosnapped node
└── RoomZones
    ├── RoomA (Area2D + CameraZone + CollisionShape2D)
    ├── RoomB (Area2D + CameraZone + CollisionShape2D)
    └── RoomC (Area2D + CameraZone + CollisionShape2D)

Tip: Size each CollisionShape2D to the visible room rectangle. For pixel-art games, align shapes to tile boundaries so there is no overlap between adjacent rooms. If rooms share a wall, a thin 1-pixel gap between shapes avoids double-triggers.


Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts7d3 checks · Risk SAFE
  • Gen Agent Trust Hub7d

    The skill provides comprehensive code examples and implementation guidelines for various camera systems in the Godot 4.3+ game engine, including 2D/3D following, screen shake, and transitions. No security issues or malicious patterns were detected.

  • Socket7d

    No alerts

  • Snyk7d

    Risk: LOW · No issues

Signed by skilld at 426e8ab. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 6 days ago.

Activeupdated 2 weeks ago

README badge

README badge for jame581/godotprompter/camera-system