Debug your project
bevy-inspector-egui
This may be obvious but this plugin is a must have for debugging.
Just add the required dependency in Cargo.toml
:
[dependencies]
bevy-inspector-egui = "0.25.2"
Then add the WorldInspectorPlugin
to your application:
use bevy::prelude::*; use bevy_inspector_egui::quick::WorldInspectorPlugin; fn main() { App::new() .add_plugins(WorldInspectorPlugin::new()) .run(); }
Now, you can browse components from all entities spawned in your game.
More informations on the project github page.
TiledMapDebugPlugin
bevy_ecs_tiled
provides a debug plugin that displays a gizmos where Tiled object are spawned.
To use it, you just have to enable the debug
feature and add the plugin to your application:
use bevy::prelude::*; use bevy_ecs_tiled::prelude::*; fn main() { App::new() .add_plugins(TiledMapDebugPlugin::default()) .run(); }
More informations in the API reference.
Physics
Both Avian and Rapier provide their own way of debugging.
It can be very useful, especially when working with colliders.
Note that physics debugging is enabled by default in all bevy_ecs_tiled
examples using physics.
To enable physics debugging in Avian, you need to simply add the corresponding plugin:
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(); }
For Rapier, you need to enable a debug plugin:
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(); }
And you also need to enable either the debug-render-2d
feature on bevy_rapier2d
crate or the rapier_debug
feature on bevy_ecs_tiled
Logging
Bevy uses the tracing
crate for logging, which is very powerful in debugging and profiling, you can find more information in the official documentation.
We recommend to enable the trace
level in your application to get more informations about what's happening, just set the RUST_LOG
environment variable to trace
:
RUST_LOG=trace cargo run
But this will be very verbose, so you can also filter the logs to only display the informations you need:
RUST_LOG=bevy_ecs_tiled=trace cargo run
This will only display logs from the bevy_ecs_tiled
crate in trace
level.