bevy_xpbd_3d_parenting
Allows children of a bevy_xpbd_3d RigidBody to exert forces on their parents.
Installation
[dependencies.bevy_xpbd_3d_parenting]
version = "0.1"
default-features = false
Quick usage example:
See the (examples)[./examples] for complete examples.
use bevy::prelude::*;
use bevy_xpbd_3d::prelude::*;
use bevy_xpbd_3d_parenting::InternalForce;
fn main() {
App::new()
.add_plugins((
DefaultPlugins,
PhysicsPlugins::new(Update),
bevy_xpbd_3d_parenting::prelude::ParentingPlugin::new(Update),
))
.add_systems(Startup, setup)
.run();
}
fn setup(
mut commands: Commands,
mut meshs: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
let mut cube = commands.spawn((
PbrBundle {
mesh: meshs.add(Mesh::from(shape::Cube { size: 1. })),
transform: Transform::from_xyz(0., 5., 0.),
..default()
},
RigidBody::Dynamic,
ExternalForce::ZERO.with_persistence(false),
Collider::capsule(1.0, 1.0),
));
cube.with_children(|cube| {
cube.spawn((
PbrBundle {
mesh: meshs.add(Mesh::from(shape::UVSphere {
radius: 0.5,
..default()
})),
transform: Transform::from_xyz(3.0, 0.0, 0.0),
..default()
},
InternalForce(Vec3::new(0., -3., 0.)),
));
});
}
Running examples
Run:
cargo r --example rotating --features bevy_xpbd_3d/async-collider
Compatibility table
| Bevy |
Bevy XPBD |
Bevy XPBD 3D Parenting |
| 0.12 |
0.3.3 |
0.1.0 |