Skip to content

Commit

Permalink
doc: add debug guide
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-bon committed Nov 11, 2024
1 parent 801f742 commit 28ba70b
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 2 deletions.
4 changes: 2 additions & 2 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

- [Minimal working example](guides/minimal.md)
- [Spawn / Despawn / Reload a map](guides/spawn_reload.md)
- [Use a physics backend](guides/physics.md)
- [Use physics](guides/physics.md)
- [Use Tiled custom properties](guides/properties.md)
- [Debug your project]()
- [Debug your project](guides/debug.md)

# Migration guides

Expand Down
88 changes: 88 additions & 0 deletions book/src/guides/debug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# 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`:

```toml
[dependencies]
bevy-inspector-egui = "0.25.2"
```

Then add the `WorldInspectorPlugin` to your application:

```rust,no_run
use bevy::prelude::*;
use bevy_inspector_egui::quick::WorldInspectorPlugin;
fn main() {
App::new()
.add_plugins(WorldInspectorPlugin::new())
.run();
}
```

Now, you can browse componentns from all entities spawned in your game.

More informations on the project [github page](https://github.com/jakobhellermann/bevy-inspector-egui).

## `TiledMapDebugPlugin`

`bevy_ecs_tiled` provides a debug plugin that displays a gizmos where Tiled object are spawned.

To use it, you just have to add the plugin to your application:

```rust,no_run
use bevy::prelude::*;
use bevy_ecs_tiled::prelude::*;
fn main() {
App::new()
.add_plugins(TiledMapDebugPlugin::default())
.run();
}
```

More informations in the [API reference](https://docs.rs/bevy_ecs_tiled/latest/bevy_ecs_tiled/debug/index.html).

## 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:

```rust,no_run
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 also need to enable a debug plugin:

```rust,no_run
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();
}
```

But you also need to enable either the `debug-render-2d` feature on `bevy_rapier2d` crate or the `rapier_debug` feature on `bevy_ecs_tiled`

0 comments on commit 28ba70b

Please sign in to comment.