/bevy-skills:bevy-physicsfrom bevy-skills
Adds Rapier physics to Bevy 0.20: rigid bodies, colliders, collision events, character controllers, and fixed-step system ordering.
Ships in bevy-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
bevy_rapier and an alternative such as Avian.Bevy core does not include a physics engine. For Bevy 0.20, use
bevy_rapier2d/bevy_rapier3d 0.37 for the mature Rapier integration. Consider
avian2d/avian3d 0.8 when its ECS-native architecture or modular solver is the
specific reason to choose it. Do not install both engines on the same simulated
entities.
[dependencies]
bevy = "0.20"
bevy_rapier3d = "0.37"
use bevy::prelude::*;
use bevy_rapier3d::prelude::*;
const PHYSICS_HZ: f64 = 60.0;
const PHYSICS_DT: f32 = 1.0 / PHYSICS_HZ as f32;
#[derive(Component)]
struct Player;
#[derive(SystemSet, Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum GamePhysics {
Drive,
React,
}
fn main() {
let mut app = App::new();
app.add_plugins(DefaultPlugins)
.insert_resource(Time::<Fixed>::from_hz(PHYSICS_HZ))
.insert_resource(TimestepMode::Fixed {
dt: PHYSICS_DT,
substeps: 1,
})
.add_plugins((
RapierPhysicsPlugin::<NoUserData>::default().in_fixed_schedule(),
RapierDebugRenderPlugin::default(),
))
.configure_sets(
FixedUpdate,
(
GamePhysics::Drive.before(PhysicsSet::SyncBackend),
GamePhysics::React.after(PhysicsSet::Writeback),
),
)
.add_systems(Startup, setup)
.add_systems(FixedUpdate, drive_player.in_set(GamePhysics::Drive))
.add_systems(FixedUpdate, react_to_collisions.in_set(GamePhysics::React));
app.run();
}
fn setup(mut commands: Commands) {
commands.spawn((
Camera3d::default(),
Transform::from_xyz(8.0, 6.0, 12.0).looking_at(Vec3::ZERO, Vec3::Y),
));
// A collider without RigidBody is fixed. Cuboid arguments are half-extents.
commands.spawn((
Name::new("Ground"),
Collider::cuboid(8.0, 0.25, 8.0),
Transform::from_xyz(0.0, -0.25, 0.0),
));
commands.spawn((
Name::new("Player"),
Player,
RigidBody::Dynamic,
Collider::ball(0.5),
Velocity::linear(Vec3::new(1.5, 0.0, 0.0)),
ActiveEvents::COLLISION_EVENTS,
Transform::from_xyz(0.0, 4.0, 0.0),
));
}
fn drive_player(mut bodies: Query<&mut Velocity, With<Player>>) {
for mut velocity in &mut bodies {
velocity.linear.x = 1.5;
}
}
fn react_to_collisions(mut events: MessageReader<CollisionEvent>) {
for event in events.read() {
if let CollisionEvent::Started(a, b, _) = event {
let _pair = (*a, *b);
}
}
}
The plugin normally runs in PostUpdate with TimestepMode::Variable. This example
deliberately moves it to FixedUpdate, makes Rapier's dt match Bevy's fixed clock,
drives bodies before PhysicsSet::SyncBackend, and reacts after
PhysicsSet::Writeback. Keep the default schedule if frame-coupled simulation is the
intent; order systems in that same schedule.
| Problem | Read |
|---|---|
| Cargo profiles, default vs fixed/interpolated stepping, multiple worlds | Setup and scheduling |
| Body types, collider shapes, mass, units, CCD, transform authority | Bodies and colliders |
| Collision messages, sensors, groups, ray/shape queries, hooks | Events, queries, and filtering |
| Kinematic character motion, controller output, joints | Controllers and joints |
| Rollback, determinism limits, headless tests, performance evidence | Determinism and testing |
bevy_rapier 0.36 targets Bevy 0.19; 0.37 is the Bevy 0.20 line. avian 0.7
targets 0.19; 0.8 targets 0.20. Stale output pairs bevy = "0.20" with 0.36.headless Cargo feature is gone in 0.37. default-features = false plus
dim3/dim2 is the headless profile; features = ["headless"] fails to resolve.Velocity fields are linear and angular, not linvel and angvel.CollisionEvent and ContactForceEvent are messages (MessageReader, not
EventReader). At least one collider must enable the matching ActiveEvents flag.PhysicsQuarantineEvent. Rapier disables bodies/colliders whose state
became NaN/inf and inserts RigidBodyDisabled/ColliderDisabled. Fix the state,
then remove that component; do not assume a silently exploded body.ReadRapierContext is a SystemParam; call .single() and handle its Result.
RapierContext is not a resource and Rapier supports multiple worlds. Batch several
queries under one filter with context.with_query_pipeline(filter, |pipeline| ..).Transform is a
teleport and commonly causes jitter; write forces, impulses, or velocity instead.KinematicCharacterController.dim2/dim3 feature.chain_weak; PhysicsSet is Rapier's
own chained set and is unaffected. Order your systems with .before/.after on
PhysicsSet as shown, never by schedule position.RapierDebugRenderPlugin is diagnostic visualization, not a renderer or a shipping
requirement.bevy-migration-0-19-to-0-20 — engine-side 0.20 breakage.bevy-core-concepts — fixed schedules and ordering.bevy-rendering — rendering and physics ownership boundary.bevy-cameras — camera rays for picking and aiming.bevy-input-actions — fixed-tick movement/aim commands.bevy-testing — deterministic app stepping and headless worlds.bevy-a11y — accessible movement, timing, and aim alternatives.bevy-voxel-pipeline — collider proxies for voxel worlds.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub chrisgliddon/bevy-skills --plugin bevy-skills32 skills in this plugin
/bevyUse when starting any Bevy task, choosing between Update and FixedUpdate, picking Cargo feature flags, or recalling which sibling skill covers ECS, assets, rendering, UI, or migration. Routes to the right Bevy 0.20 skill and pins the engine version for downstream snippets./bevy-a11yUse when designing or auditing high-standard video-game accessibility in Bevy 0.20, integrating screen readers and focus navigation, supporting adaptive controllers and complete remapping, implementing captions or audio description, checking contrast and motion safety, or building disabled-player test evidence./bevy-animationUse when wiring `AnimationPlayer` + `AnimationGraphHandle`, building an `AnimationGraph` from glTF clips, blending state-driven animations with `AnimationTransitions::play`, isolating body parts with `AnimationMask`, firing gameplay sync via `#[derive(AnimationEvent)]` + `On<E>` observers, tweening with `AnimatableCurve` / `EaseFunction` / `CubicSegment::new_bezier_easing` from `bevy::curve`, or applying the 12 Basic Principles of Animation to 3D characters in Bevy 0.20./bevy-assetsUse when loading with `AssetServer::load` or `AssetServer::load_builder().with_settings(..)`, holding a `Handle<T>`, spawning a glTF scene with `WorldAssetRoot` (`Handle<WorldAsset>`), mutating through `Assets::get_mut` / `AssetMut`, polling `LoadState::is_loaded`, resolving an `AssetPath`, or replacing `AssetId::invalid()` with `Option<AssetId<T>>` in Bevy 0.20./bevy-audioUse when implementing audio in Bevy 0.20 with `AudioPlayer`, `PlaybackSettings`, `AudioSink` or `SpatialAudioSink`, spatial listeners, application mix groups, ambience/music transitions, asset lifetime, browser gesture restrictions, or choosing built-in audio versus `bevy_seedling 0.8`./bevy-camerasUse when spawning `Camera3d` or `Camera2d`, choosing a `Projection`, rendering to an image with the `RenderTarget` component, adding `Hdr` / `Tonemapping::Linear` / `ScreenSpaceTransmission` to a camera, wiring `FreeCamera`, `PanCamera` or the new `PanOrbitCamera` from `bevy::camera_controller`, ordering views with `Camera::order`, or setting a per-camera `AmbientLight` in Bevy 0.20.Other plugins' skills for the same job