bevy-physics-3d
БесплатноБез исполняемых скриптовНе проверенBevy ECS skill for 3D physics. Keywords: Bevy, physics, ECS, 3D.
от thedivergentai★ 1 019 звёзд на GitHubОб этом скилле
Bevy 3D physics
When to use
Load this when a Bevy app needs simulated 3D bodies (props, impulses, constraints) before choosing a solver. Pair with bevy-character-movement for player motion that should not be a rigid body.
ECS shape
- Components own velocity, mass, and a sphere radius for props you simulate yourself.
- Resources own gravity.
- Systems integrate on
FixedUpdate, then separate overlapping spheres..chain()runs separation after the step. - Schedule: the fixed step is the clock. A separate solver plugin can replace the integrator when you need joints and a broadphase. This file does not name that plugin's types. Player locomotion stays on bevy-character-movement.
Ownership
| Need | Bevy shape |
|---|---|
| Simulated prop | Body plus Transform, integrated on FixedUpdate |
| Player locomotion | bevy-character-movement, not this integrator |
| Joints and ragdolls | A separate solver plugin once those features are required. This file does not name that plugin's types |
| Layers and masks | A Layer component you define, filtered in the overlap system |
Scope
- Gravity, velocity, and sphere overlap are ordinary components stepped on
FixedUpdate. - Joints, ragdolls, and continuous collision belong to a physics solver you add as a plugin. This skill does not call that plugin's types.
Examples
[package]
name = "physics3d"
version = "0.1.0"
edition = "2021"
[dependencies]
bevy = "0.20"
Integrate velocity under gravity, then push overlapping spheres apart. Both systems write Body and Transform, so they run as one chain.
#[derive(Component)]
struct Body {
velocity: Vec3,
mass: f32,
radius: f32,
}
#[derive(Component)]
struct Layer(u32);
#[derive(Resource)]
struct Gravity(Vec3);
fn integrate(
time: Res<Time<Fixed>>,
gravity: Res<Gravity>,
mut bodies: Query<(&mut Transform, &mut Body)>,
) {
let dt = time.delta_secs();
for (mut tf, mut body) in &mut bodies {
body.velocity += gravity.0 * dt;
tf.translation += body.velocity * dt;
if tf.translation.y < body.radius {
tf.translation.y = body.radius;
body.velocity.y = body.velocity.y.max(0.0);
}
}
}
fn separate(mut bodies: Query<(Entity, &mut Transform, &mut Body, &Layer)>) {
let mut pairs: Vec<(Entity, Entity)> = Vec::new();
for (a, tf_a, body_a, layer_a) in &bodies {
for (b, tf_b, body_b, layer_b) in &bodies {
if a.index() >= b.index() || layer_a.0 != layer_b.0 {
continue;
}
let min = body_a.radius + body_b.radius;
if tf_a.translation.distance(tf_b.translation) < min {
pairs.push((a, b));
}
}
}
for (a, b) in pairs {
let Ok([(_, mut tf_a, mut body_a, _), (_, mut tf_b, mut body_b, _)]) =
bodies.get_many_mut([a, b])
else {
continue;
};
let delta = tf_b.translation - tf_a.translation;
let dist = delta.length();
let min = body_a.radius + body_b.radius;
if dist >= min || dist == 0.0 {
continue;
}
let normal = delta / dist;
let push = (min - dist) * 0.5;
tf_a.translation -= normal * push;
tf_b.translation += normal * push;
let rel = (body_b.velocity - body_a.velocity).dot(normal);
if rel < 0.0 {
let inv_a = 1.0 / body_a.mass.max(0.001);
let inv_b = 1.0 / body_b.mass.max(0.001);
let impulse = -rel / (inv_a + inv_b);
body_a.velocity -= normal * impulse * inv_a;
body_b.velocity += normal * impulse * inv_b;
}
}
}
pub struct PhysicsPlugin;
impl Plugin for PhysicsPlugin {
fn build(&self, app: &mut App) {
app.insert_resource(Gravity(Vec3::new(0.0, -9.8, 0.0)))
.add_systems(FixedUpdate, (integrate, separate).chain());
}
}
An impulse adds velocity. Spawn places a crate above the ground plane so the next fixed step can fall.
#[derive(Component)]
struct Body {
velocity: Vec3,
mass: f32,
radius: f32,
}
fn kick(mut bodies: Query<&mut Body>) {
for mut body in &mut bodies {
body.velocity += Vec3::new(0.0, 6.0, 2.0);
}
}
fn spawn_crate(mut commands: Commands) {
commands.spawn((
Transform::from_xyz(0.0, 2.0, 0.0),
Body {
velocity: Vec3::ZERO,
mass: 2.0,
radius: 0.5,
},
));
}
A ray against the ground plane reports the hit point without a physics crate.
fn ray_ground(origin: Vec3, dir: Vec3) -> Option<Vec3> {
if dir.y >= 0.0 {
return None;
}
let t = -origin.y / dir.y;
if t < 0.0 {
return None;
}
Some(origin + dir * t)
}
fn aim_at_ground(aimers: Query<&Transform>, mut gizmos: Gizmos) {
for tf in &aimers {
let dir = tf.forward().as_vec3();
if let Some(hit) = ray
Установить bevy-physics-3d в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл bevy-physics-3d?
Bevy ECS skill for 3D physics. Keywords: Bevy, physics, ECS, 3D.
Как установить скилл bevy-physics-3d?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл bevy-physics-3d запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic