Debug your project
Logging
Bevy uses the tracing
crate for logging, which is very powerful for debugging and profiling.
You can find more information in the official documentation.
To get detailed information about what's happening in your app, set the RUST_LOG
environment variable to trace
:
RUST_LOG=trace cargo run
This will show all logs at the trace
level, but it can be very verbose.
To filter logs and only display information from bevy_ecs_tiled
, use:
RUST_LOG=bevy_ecs_tiled=trace cargo run
This will only display logs from the bevy_ecs_tiled
crate at the trace
level.
bevy_ecs_tiled
Debug Plugins
When the debug
feature is enabled, bevy_ecs_tiled
provides several debug plugins to help visualize and inspect your maps.
You can enable all debug plugins at once by adding the TiledDebugPluginGroup
to your app:
use bevy::prelude::*; use bevy_ecs_tiled::prelude::*; fn main() { App::new() .add_plugins(TiledDebugPluginGroup) .run(); }
Or add them individually as needed:
TiledDebugObjectsPlugin
: Displays anarrow_2d
and a polyline outlineGizmos
at each Tiled object's position and shape.TiledDebugTilesPlugin
: Shows thebevy_ecs_tilemap
tile index (TilePos
) above each tile.TiledDebugWorldChunkPlugin
: Draws aGizmos
rectangle for each map boundary and world render chunk.TiledDebugAxisPlugin
: Displays aGizmos
axes marker at the world origin.
For more details, see the API reference.
Third-Party Debugging Tools
bevy-inspector-egui
This plugin is highly recommended for debugging and inspecting your game world.
Add the dependency to your Cargo.toml
:
[dependencies]
bevy-inspector-egui = "0.30"
Then add the WorldInspectorPlugin
to your application:
use bevy::prelude::*; use bevy_inspector_egui::quick::WorldInspectorPlugin; fn main() { App::new() .add_plugins(DefaultPlugins) .add_plugins(EguiPlugin { enable_multipass_for_primary_context: true }) .add_plugins(WorldInspectorPlugin::new()) .run(); }
Now, you can browse and edit components from all entities spawned in your game in real time.
More information is available on the project's GitHub page.
Physics Plugins
Both Avian and Rapier provide their own debug visualization plugins, which are invaluable when working with colliders and physics.
Avian Physics Debugging:
use bevy::prelude::*; use avian2d::prelude::*; fn main() { App::new() // Add Avian regular plugin .add_plugins(PhysicsPlugins::default().with_length_unit(100.0)) // Add Avian debug plugin .add_plugins(PhysicsDebugPlugin::default()) .run(); }
Rapier Physics Debugging:
use bevy::prelude::*; use bevy_rapier2d::prelude::*; fn main() { App::new() // Add Rapier regular plugin .add_plugins(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0)) // Add Rapier debug plugin .add_plugins(RapierDebugRenderPlugin::default()) .run(); }
Note:
For Rapier, you must enable either thedebug-render-2d
feature on thebevy_rapier2d
crate or therapier_debug
feature onbevy_ecs_tiled
.