xiaohongshu
xiaohongshu
godot-sync-parallax
Use when Godot ParallaxBackground/ParallaxLayer nodes show incorrect positions in editor due to parallax multipliers. Calculates correct editor positions based on camera start position and parallax motion scale. Makes parallax layers preview realistically in editor, matching gameplay appearance.
Full skill instructions
Parallax layers need special math for correct editor preview. Motion scale affects runtime position.
Parallax systems in Godot are complex:
# Godot's parallax formula:
final_position = layer_position - (camera_position * motion_scale)
The problem:
layer_positionlayer_position - (camera_position * motion_scale)The solution:
Calculate correct layer_position so runtime appearance matches intended design.
# parallax_background.tscn
[node name="ParallaxBackground" type="ParallaxBackground"]
[node name="SkyLayer" type="ParallaxLayer" parent="."]
motion_scale = Vector2(0.2, 0.2) # Slow parallax
position = Vector2(0, 0)
# Camera starts at (640, 360)
# Runtime position: 0 - (640 * 0.2) = -128 (WRONG!)
# Sky layer appears shifted left in game
After sync:
[node name="SkyLayer" type="ParallaxLayer" parent="."]
motion_scale = Vector2(0.2, 0.2)
position = Vector2(128, 72) # Corrected!
# Runtime position: 128 - (640 * 0.2) = 0 (CORRECT!)
# Sky layer appears centered in game, matching editor
Identifies parallax systems:
[node name="ParallaxBackground" type="ParallaxBackground"]
scroll_offset = Vector2(0, 0)
scroll_base_scale = Vector2(1, 1)
[node name="Layer1" type="ParallaxLayer" parent="."]
motion_scale = Vector2(0.5, 0.5)
motion_offset = Vector2(0, 0)
[node name="SkyLayer" parent="ParallaxBackground"]
motion_scale = Vector2(0.1, 0.1) # Very slow (far away)
[node name="MountainsLayer" parent="ParallaxBackground"]
motion_scale = Vector2(0.3, 0.3) # Slow (middle distance)
[node name="TreesLayer" parent="ParallaxBackground"]
motion_scale = Vector2(0.7, 0.7) # Fast (close)
Creating multi-layer parallax effect in editor.
Layers appear at wrong positions in game.
Want WYSIWYG for parallax systems.
Complex parallax with many layers at different scales.
displayed_position = layer_position - (camera_position * motion_scale)
layer_position = desired_position + (camera_position * motion_scale)
Want sky layer centered at (0, 0) in game:
Before (Broken):
[node name="SkyLayer" type="ParallaxLayer"]
motion_scale = Vector2(0.2, 0.2)
position = Vector2(0, 0)
# Sprite at (0, 0) relative to layer
# Camera at (640, 360)
# Runtime: 0 - (640 * 0.2) = -128
# Sky appears -128 pixels left (WRONG)
After (Fixed):
[node name="SkyLayer" type="ParallaxLayer"]
motion_scale = Vector2(0.2, 0.2)
position = Vector2(128, 72) # Corrected
# Sprite at (0, 0) relative to layer
# Runtime: 128 - (640 * 0.2) = 0
# Sky appears centered (CORRECT)
Before (All at origin):
[node name="Sky" type="ParallaxLayer"]
motion_scale = Vector2(0.1, 0.1)
position = Vector2(0, 0)
[node name="Mountains" type="ParallaxLayer"]
motion_scale = Vector2(0.3, 0.3)
position = Vector2(0, 0)
[node name="Trees" type="ParallaxLayer"]
motion_scale = Vector2(0.7, 0.7)
position = Vector2(0, 0)
# All layers shifted left at runtime
After (Corrected):
[node name="Sky" type="ParallaxLayer"]
motion_scale = Vector2(0.1, 0.1)
position = Vector2(64, 36) # 640*0.1, 360*0.1
[node name="Mountains" type="ParallaxLayer"]
motion_scale = Vector2(0.3, 0.3)
position = Vector2(192, 108) # 640*0.3, 360*0.3
[node name="Trees" type="ParallaxLayer"]
motion_scale = Vector2(0.7, 0.7)
position = Vector2(448, 252) # 640*0.7, 360*0.7
# All layers centered correctly at runtime
Combined formula:
displayed_position = (layer_position + motion_offset) - (camera_position * motion_scale)
Syncing considers both properties.
Identifies parallax systems:
Detects camera:
Calculates corrections:
Works with:
Don't sync if:
[node name="CloudsLayer" type="ParallaxLayer"]
motion_scale = Vector2(0.2, 0) # Horizontal only
motion_mirroring = Vector2(1280, 0) # Repeat horizontally
Sync: Correct horizontal position only.
[node name="SkyLayer" type="ParallaxLayer"]
motion_scale = Vector2(0, 0.1) # Vertical only
Sync: Correct vertical position only.
[node name="BackgroundLayer" type="ParallaxLayer"]
motion_scale = Vector2(0.3, 0.3) # Both axes
Sync: Correct both x and y positions.
After syncing, validates:
# Parallax layer corrected for camera start: (640, 360)
# motion_scale: (0.2, 0.2)
# Formula: position = desired_runtime_position + (camera * motion_scale)
# Calculation: (0, 0) + (640 * 0.2, 360 * 0.2) = (128, 72)
Clear documentation shows calculation method.
| Issue | Cause | Solution |
|---|---|---|
| Layer shifted left in game | position = (0,0), motion_scale < 1 | Add offset: camera * motion_scale |
| Layer jumps at start | Editor position ≠ runtime position | Sync positions using formula |
| Layers misaligned | Different camera assumptions | Consistent camera start position |
| Preview doesn't match game | Parallax math not considered | Apply inverse parallax formula |
Parallax systems are efficient but:
Syncing positions doesn't affect performance, only editor usability.
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