created_at2022-11-03 15:57:23.144931
updated_at2022-12-24 11:33:02.144604
descriptionBevy plugin for more ergonomic 2d.



bevy_mod_2d_hierarchy MIT/Apache 2.0

Bevy plugin for more ergonomic 2D.

  • Specialized 2D transform and propagation systems.
  • Independent of the Bevy 3D transform systems, can use both in the same project.
  • Compatible with existing plugins as long as they only query for GlobalTransform and not Transform.
  • Control 2D transform propagation behaviour.
  • Performance similar to the 3D Transform. The propagation control has a cost, but some operations cheaper in 2D.
  • No quaternions.
  • Supports Bevy 0.9


Add the dependency to your Cargo.toml

bevy_mod_2d_hierarchy = "0.3"

Add the plugin to your Bevy App:

use bevy::prelude::*;
use bevy_mod_2d_hierarachy::prelude::*;

fn main() {
    // .. rest of systems etc

Then spawn some sprites

pub fn spawn(
    mut commands: Commands,
    asset_server: Res<AssetServer>,
) {
    commands.spawn(SpriteBundle2 {
        texture: asset_server.load("sprite.png"),
        transform2: Transform2::from_rotation(0.5 * PI).with_scale(3.),
    .with_children(|builder| {
        builder.spawn(SpriteBundle2 {
            sprite: Sprite { 
                color: Color::YELLOW, 
            texture: asset_server.load("sprite.png"),
            transform2: Transform2::from_xy(0., 32.),
            propagate: Propagate::TRANSLATION,


See also:

Major differences Transform2d vs 2d_hierarchy:

  • Transform2d is compatible with systems that query for Transform. No 3rd party physics and collision detection crates will work with 2d_hierarchy; for that reason alone, Transform2d is the better choice for most users.
  • 2d_hierarchy is marginally more efficient (but neither library is performance focused, and you probably won't even be to able to measure the difference). Might be room to improve 2d_hierarchy
  • 2d_hierarchy uses a single f32 for scale and Transform2d uses a Vec2.
  • Transform2d has a seperate component for Z depth, while 2d_hierarchy keeps it in the transform.
  • Because 2d_hierarchy is incompatible with Transform you can't use Bevy's builtin bundles like SpriteBundle and have to use the provided replacement SpriteBundle2 (or make your own bundle).
  • You can have mix entities with Transform2d and regular Transforms in the same transform tree. 2d_hierarchy you can't. Useful if you want to mix 2d and 3d.
  • Transform2d there is the worry of transform synchronization problems, but they aren't likely and should be easy to fix etc.
  • 2d_hierarchy you can control which properties are propagated down the transform tree (useful for text captions above rotated and scaled sprites).

You could even use Transform2d and 2d_hierarchy together if you really wanted. That would be really silly though.

Commit count: 21

cargo fmt