Skills

Bevy Adapt 3d To 2d

Bevy ECS skill for moving a Bevy game from 3D to 2D.

Install

npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-adapt-3d-to-2d -g -a claude-code -y
Category
Media
Updated
19d ago
License
LGPL-3.0
Context cost
Mediumabout 1,769 tokens
Runs scripts
No, instructions only

What it does

Bevy ECS skill for moving a Bevy game from 3D to 2D. Keywords: Bevy, 3D, 2D, adapt, sprite, camera.

Bevy adapt 3D to 2D

When to use

Load this when a 3D design should render as sprites or billboards. Gameplay components stay. Render components change.

ECS shape

  • Draw: replace mesh and PBR material entities' render parts with Sprite where a billboard is enough.
  • Camera: use Camera2d from bevy-camera-systems.
  • Lights: 3D light entities are not required for an unlit sprite. Do not leave clustered-light assumptions in gameplay code.

What stays and what changes

PieceBevy idiom
Gameplay on the actorKeep the same components. Swap render components for Sprite.
ViewCamera2d.
Draw orderA DrawOrder component you store, then write into Transform.

Examples

[dependencies]
bevy = "0.20"

Gameplay components stay on the entity. The 3D render components come off, and a Sprite goes on. Camera2d is the view.

#[derive(Component)]
struct Actor;

#[derive(Component)]
struct DrawOrder(f32);

fn spawn_flat_view(mut commands: Commands) {
    commands.spawn(Camera2d);
}

fn present_as_sprites(
    mut commands: Commands,
    asset_server: Res<AssetServer>,
    actors: Query<(Entity, &DrawOrder), With<Actor>>,
) {
    let image = asset_server.load("actors/hero.png");
    for (entity, order) in &actors {
        commands
            .entity(entity)
            .remove::<Mesh3d>()
            .remove::<MeshMaterial3d<StandardMaterial>>()
            .insert((
                Sprite {
                    image: image.clone(),
                    custom_size: Some(Vec2::new(64.0, 64.0)),
                    ..default()
                },
                Transform::from_xyz(0.0, order.0, 0.0),
            ));
    }
}

A new actor can spawn already flat. The same Actor component is what gameplay systems query.

#[derive(Component)]
struct Actor;
Read the whole SKILL.md on GitHub

More in Media