#Creating a Rapier collider from a mesh

8 messages · Page 1 of 1 (latest)

vernal flame
#

Hello y'all,

I've been trying to make a collider from a mesh inside the following bevy bundle:

`
(
PbrBundle {
mesh: body_mesh,
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
transform: Transform::from_xyz(0.0, 20.0, 0.0),
..default()
},
//physics properties
RigidBody::Dynamic, // set this object to be a dynamic rigid body
Collider::from_bevy_mesh(body_mesh, ???),
Restitution::coefficient(0.0),

    )

`

but "from_bev_mesh" wants a reference to a reference to &ComputedColliderShape which is either a Trimesh or a ConvexDecomposition.

How would I make a trimesh/convexdecomposition from my mesh to fill the second field?

novel galleon
#

You probably just want Collider::from_bevy_mesh(mesh, &ComputedColliderShape::TriMesh).unwrap(). At least that's what I'm using in my game.

The ComputedColliderShape is just an enum that instructs from_bevy_mesh how to represent the geometry (as far as I know).

vernal flame
wooden prairie
vernal flame
wooden prairie
#

Add AsyncCollider(ComputedColliderShape::TriMesh) as a component

vernal flame
vernal flame