xiaohongshu
xiaohongshu
godot-sync-camera-positions
Use when Godot background layers or elements follow the camera at runtime but show incorrect position in editor. Detects camera-following patterns and syncs editor position to match typical runtime state. Makes editor preview accurately show what players will see during gameplay.
Full skill instructions
Editor preview should show realistic gameplay view. Camera-following elements need special handling.
Finds patterns like:
# background.gd
extends Sprite2D
func _process(delta):
position = camera.position # Follows camera at runtime
# background.tscn
[node name="Background" type="Sprite2D"]
position = Vector2(0, 0) # Editor shows at origin
# RESULT: Editor shows background at (0,0)
# But in game, background is at camera position (e.g., 500, 300)
# Level designer sees wrong view!
Resolves to:
# background.gd (unchanged - runtime behavior same)
func _process(delta):
position = camera.position
# background.tscn (updated to show typical camera position)
[node name="Background" type="Sprite2D"]
position = Vector2(500, 300) # Camera starting position
# RESULT: Editor preview now shows realistic gameplay view
Identifies camera-following code:
func _process(delta):
position = camera.position # CAMERA FOLLOW
position = camera.global_position
position = get_viewport().get_camera_2d().position
func _process(delta):
position = player.position # Player follows camera
# Background follows player → effectively follows camera
func _process(delta):
position = camera.position + offset # CAMERA FOLLOW with offset
position = player.position + Vector2(0, -100)
func _process(delta):
position = position.lerp(camera.position, 0.1) # Smooth camera follow
Backgrounds that follow camera for infinite scrolling effect.
World-space UI that stays with camera.
Want to see what area looks like during gameplay.
Any element positioned relative to camera.
Set editor position to where camera starts.
Best for: Most camera-following elements.
# background.gd
func _process(delta):
position = camera.position
# Determine camera start position (from Level scene or project settings)
# Update background.tscn to position = camera_start_position
Set editor position to player spawn + offset.
Best for: Elements following player with offset.
# cloud.gd
func _process(delta):
position = player.position + Vector2(0, -200) # Above player
# Find player spawn point
# Update cloud.tscn to position = player_spawn + Vector2(0, -200)
Add metadata to scene explaining runtime behavior.
Best for: Complex camera following logic.
# Metadata in .tscn
[node name="Background"]
metadata/_editor_note = "Runtime: follows camera at camera.position"
Identifies camera-following patterns:
# CAMERA-FOLLOWING (syncs these)
position = camera.position
position = $"/root/Main/Camera".position
position = player.position # If player has camera
position.x = camera.position.x # Horizontal follow
Skips non-camera patterns:
# NOT CAMERA-FOLLOWING (skips these)
position = target_position # Generic target
position = waypoints[index] # Waypoint following
position = mouse_position # Mouse following
Before:
# background.gd
extends Sprite2D
@onready var camera = $"/root/Main/Camera2D"
func _process(delta):
position = camera.position
# background.tscn
[node name="Background" type="Sprite2D"]
position = Vector2(0, 0)
texture = preload("res://assets/sky.png")
Editor view: Background at origin (0, 0) - wrong! Game view: Background at camera position (640, 360) - correct!
After Sync:
# background.gd (unchanged)
extends Sprite2D
@onready var camera = $"/root/Main/Camera2D"
func _process(delta):
# Runtime: follows camera position
position = camera.position
# background.tscn (updated)
[node name="Background" type="Sprite2D"]
position = Vector2(640, 360) # Camera start position
texture = preload("res://assets/sky.png")
Editor view: Background at (640, 360) - matches gameplay! Game view: Background at camera position - same as before!
Before:
# cloud.gd
extends Sprite2D
func _process(delta):
position = player.position + Vector2(0, -200)
# cloud.tscn
[node name="Cloud" type="Sprite2D"]
position = Vector2(0, 0)
After Sync:
# cloud.gd (unchanged)
func _process(delta):
# Runtime: 200 pixels above player
position = player.position + Vector2(0, -200)
# cloud.tscn (updated to show above player spawn)
[node name="Cloud" type="Sprite2D"]
position = Vector2(320, -20) # Player spawns at (320, 180)
# Search for Camera2D nodes
grep -r "type=\"Camera2D\"" scenes/
# Find position value in camera's parent scene
# Check viewport size (camera typically starts at center)
# Default: 1280x720 → camera at (640, 360)
If detection uncertain, ask: "Where does your camera start? (e.g., center of viewport, player position)"
Works with:
Don't sync if:
func _process(delta):
position.x = camera.position.x
# Vertical position fixed, horizontal follows camera
Sync: Set editor x to camera start x, keep y unchanged.
func _process(delta):
position = position.lerp(camera.position, smoothness)
Sync: Set editor position to camera start (eventual position).
func _process(delta):
position = camera.position.clamp(min_bounds, max_bounds)
Sync: Set editor position to clamped camera start position.
After syncing, validates:
# Runtime behavior:
# - Follows camera.position in _process
# - Editor position set to camera start: (640, 360)
# - During gameplay, position will match camera exactly
Clear documentation prevents confusion when code and editor positions differ intentionally.
Intelligent detection minimizes user input needed.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience