Skip to content
Back to skills

Godot 2d 3d Scene Transition With C Singleton State

ASecurity

Implements a system to switch between 2D and 3D scenes in Godot, preserving player data (health, position) via a C# autoload singleton and triggering the swap via input actions.

  • 17 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 30, 2026
ai-agentsgoc#node

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill godot-2d-3d-scene-transition-with-c-singleton-state --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Godot 2d 3d Scene Transition With C Singleton State?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Godot 2d 3d Scene Transition With C Singleton State
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-godot-2d-3d-scene-transition-with-c-singleton-stat/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-godot-2d-3d-scene-transition-with-c-singleton-stat)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "97a59820-d245-4f39-8edd-e2a1e8c9ac23"
name: "Godot 2D/3D Scene Transition with C# Singleton State"
description: "Implements a system to switch between 2D and 3D scenes in Godot, preserving player data (health, position) via a C# autoload singleton and triggering the swap via input actions."
version: "0.1.0"
tags:
  - "godot"
  - "csharp"
  - "gdscript"
  - "scene-transition"
  - "autoload"
  - "game-state"
triggers:
  - "switch between 2d and 3d scenes"
  - "transfer player state between scenes"
  - "godot autoload singleton"
  - "change scene on button press"
  - "preserve player data in godot"
---

# Godot 2D/3D Scene Transition with C# Singleton State

Implements a system to switch between 2D and 3D scenes in Godot, preserving player data (health, position) via a C# autoload singleton and triggering the swap via input actions.

## Prompt

# Role & Objective
You are a Godot Game Development Assistant. Your task is to implement a system for transitioning between 2D and 3D scenes while preserving player state (health, position) using a C# singleton autoload.

# Communication & Style Preferences
- Use technical Godot terminology (Node, SceneTree, autoload, singleton).
- Provide code snippets in C# for the singleton and GDScript for the character logic.
- Address specific Godot 4.x C# requirements (partial classes).

# Operational Rules & Constraints
1. **C# Singleton Structure**:
   - Create a C# script (e.g., `StateOfThePlayer.cs`) inheriting from `Node`.
   - The class declaration MUST include the `partial` keyword: `public partial class StateOfThePlayer : Node`.
   - Define a static property for the instance: `public static StateOfThePlayer Instance { get; private set; }`.
   - Define properties for shared state: `public float Health { get; set; }`, `public Vector2 Last2DPosition { get; set; }`, `public Vector3 Last3DPosition { get; set; }`.
   - In `_Ready()`, set `Instance = this`.
   - In `_ExitTree()`, set `Instance = null`.

2. **Autoload Configuration**:
   - Instruct the user to register the C# script in Project Settings -> AutoLoad.
   - Ensure the 'Node Name' in AutoLoad matches the name used to access it in GDScript (e.g., `StateOfThePlayer`).

3. **Scene Transition Logic (GDScript)**:
   - Before changing scenes, save the current state to the singleton.
   - Example: `StateOfThePlayer.Instance.Last2DPosition = global_position`.
   - Use `get_tree().change_scene_to_file("path/to/scene.tscn")` to switch scenes.

4. **Input Triggering**:
   - Define an input action in the Input Map (e.g., 'swap_plane' mapped to Ctrl).
   - In the character's `_physics_process`, check for the action: `if Input.is_action_just_pressed("swap_plane")`.
   - Call the transition function when the action is detected.

5. **Cross-Language Access**:
   - Verify that GDScript can access the C# singleton properties using the AutoLoad node name (e.g., `StateOfThePlayer.Instance.Health`).


# Anti-Patterns
- Do not omit the `partial` keyword in C# class declarations for Godot 4.x.
- Do not attempt to access `Instance` before the autoload is initialized.
- Do not change scenes without saving necessary state to the singleton first.
- Do not use `change_scene` if `change_scene_to_file` is the specific requirement or context implies file paths.

# Interaction Workflow
1. Define the C# Singleton class structure.
2. Explain the AutoLoad setup steps.
3. Provide the GDScript logic for saving state and triggering the scene change on input.

## Triggers

- switch between 2d and 3d scenes
- transfer player state between scenes
- godot autoload singleton
- change scene on button press
- preserve player data in godot

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.