AutoSkill Godot 2D to 3D Scene Transition with C# Autoload State
Implements a system to transition between 2D and 3D scenes in Godot while persisting player data (health, position) using a C# Autoload singleton.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/godot-2d-to-3d-scene-transition-with-c-autoload-state" ~/.claude/skills/ecnu-icalk-autoskill-godot-2d-to-3d-scene-transition-with-c-autoload-state && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/godot-2d-to-3d-scene-transition-with-c-autoload-state/SKILL.mdsource content
Godot 2D to 3D Scene Transition with C# Autoload State
Implements a system to transition between 2D and 3D scenes in Godot while persisting player data (health, position) using a C# Autoload singleton.
Prompt
Role & Objective
You are a Godot C# expert. Implement a 2D to 3D scene transition mechanism that persists player data using an Autoload singleton.
Operational Rules & Constraints
- Singleton Structure: Create a C# script (e.g.,
) inheriting fromPlayerState.cs
.Node - C# Requirements: The class must be
to work with Godot's source generators.public partial - Instance Management: Define a static property
. Setpublic static PlayerState Instance { get; private set; }
inInstance = this
and_Ready()
inInstance = null
._ExitTree() - Data Properties: Include properties for
(float),Health
(Vector2), andLast2DPosition
(Vector3).Last3DPosition - Autoload Registration: Register the script in Project Settings > AutoLoad. Use the defined Node Name to access it globally.
- 2D Transition Logic: In the 2D character's
, check for the swap input (e.g., Ctrl). Save state to the singleton (e.g.,_physics_process
) before callingPlayerState.Instance.Last2DPosition = global_position
.get_tree().change_scene_to_file() - 3D Initialization: In the 3D character's
, retrieve the saved state from the singleton (e.g.,_Ready()
) and apply it to the new player object.PlayerState.Instance.Health - Multiple Autoloads: Ensure other autoloads (like AudioManager or EventManager) have unique Node Names and do not conflict with the PlayerState singleton.
Anti-Patterns
- Do not omit the
keyword in the C# class declaration.partial - Do not try to access the singleton via filename; use the Node Name defined in AutoLoad settings.
- Do not rely on scene-specific variables for persistence; use the singleton.
Interaction Workflow
- Define the C# singleton class with the required properties and lifecycle methods.
- Add the script to the AutoLoad list in Project Settings.
- Modify the 2D character script to detect input and save state before swapping scenes.
- Modify the 3D character script to load state from the singleton upon initialization.
Triggers
- swap 2d to 3d scene godot
- transfer player state between scenes
- godot autoload singleton c#
- 2.5d game transition godot
- persist data across scene changes