rust-adventure / super-corgo

3 stars 2 forks source link

Only Single Jump should be possible #1

Open ChristopherBiscardi opened 3 years ago

ChristopherBiscardi commented 3 years ago

Currently the "player" can jump infinitely, resulting in double, triple, etc jumps, should only be able to jump if is in contact with a surface.

ChristopherBiscardi commented 3 years ago

Possibly "detect when in contact with components labelled "ground" or whatnot

/* Test intersections inside of a system. */
fn test_intersections(query_pipeline: Res<QueryPipeline>, collider_query: QueryPipelineColliderComponentsQuery) {
    // Wrap the bevy query so it can be used by the query pipeline.
    let collider_set = QueryPipelineColliderComponentsSet(&collider_query);

    let shape = Cuboid::new(Vec2::new(1.0, 2.0).into());
    let shape_pos = (Vec2::new(0.0, 1.0), 0.8).into();
    let groups = InteractionGroups::all();
    let filter = None;

    query_pipeline.intersections_with_shape(
        &collider_set, &shape_pos, &shape, groups, filter, |handle| {
        println!("The entity {:?} intersects our shape.", handle.entity());
        true // Return `false` instead if we want to stop searching for other colliders that contain this point.
    });

    let aabb = AABB::new(Vec2::new(-1.0, -2.0).into(), Vec2::new(1.0, 2.0).into());
    query_pipeline.colliders_with_aabb_intersecting_aabb(&aabb, |handle| {
        println!("The entity {:?} has an AABB intersecting our test AABB", handle.entity());
        true // Return `false` instead if we want to stop searching for other colliders that contain this point.
    });
}

https://rapier.rs/docs/user_guides/bevy_plugin/scene_queries

ChristopherBiscardi commented 3 years ago

Collision detection is implemented for respawn floor already. Should be able to tag platforms with a Platform struct and filter collisions to see if corgi is on a platform to tell if corgi should be able to jump.