#How do you get points of where collisions happened between two colliders for rapier?

1 messages · Page 1 of 1 (latest)

pliant condor
#

I have the following code to rapidly spawn and de-spawn cubes to showcase where collisions happen

/// checks for collisions, and briefly spawns cubes to showcase 
#[allow(dead_code)]
pub fn display_contacts(
    mut commands: Commands, 
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<StandardMaterial>>,
    rapier_context: Res<RapierContext>) {

    for contact in rapier_context.contact_pairs() {
        //println!("{:#?} and {:#?} collided with eachother", contact.collider1(), contact.collider2());
        for manifold in contact.manifolds() {
            //println!("contact points are: {:#?}", manifold.points());
            for contact_point in manifold.points() {
                let cube_size = 0.03 as f32;
                commands.spawn(
                    (
                        PbrBundle {
                            mesh: meshes.add(shape::Cube{size: cube_size}.into()),
                            material: materials.add(Color::rgb(0.1, 0.5, 0.3).into()),
                            transform: Transform::from_translation(contact_point.local_p1()),
                            ..default()
                        },
                        DespawnTimer::new(0.3 as f32),
                    )
                );      
            }
        }

    }
}

However, the cubes spawn like in the attached image below, and not at the point of collisions.

What am I missing?

tight ledge
#

Those contact points are local/relative to the transform of the collider. i.e they are not a global position

pliant condor