bevy_physimple icon indicating copy to clipboard operation
bevy_physimple copied to clipboard

Square sensor only detects overlap at edges of another square

Open Havegum opened this issue 2 years ago • 3 comments

I ran into this issue trying to create a square hitbox that could detect which mobs falls within it. Below are images that illustrate the issue and a repository to reproduce.

The issue

A square sensor only registers overlapping bodies of square collision shape at the edges.

Expected result

The sensor registers the overlapping bodies throughout the area of the sensor.

Illustration

A controllable blue square has a light-gray sensor attached to detect the red square: Screenshot 2022-03-12 at 14 49 46 The sensor detects the red square and turns yellow when the near edges are close: Screenshot 2022-03-12 at 14 49 52 However, as the blue square moves further, the sensor no longer detects the red square: Screenshot 2022-03-12 at 14 49 58

Code to reproduce

  • Clone and run this repo:

    git clone [email protected]:Havegum/bevy_physimple_sensor_issue.git
    cd bevy_physimple_sensor_issue
    cargo run
    
  • Use keyboard arrows or WASD to move the blue square.

  • Observe that the sensor changes color only when its edges touches the red square.

Havegum avatar Mar 12 '22 14:03 Havegum

Issue seems to be part of the continuous collision, which barely works(I need to revise the system again, but I'm now busy with work and uni).

I would advise against using the provided Vel type(unless really needs the continuous collision), as it 'solves' the problem(by using normal collision)

RustyStriker avatar Mar 13 '22 18:03 RustyStriker

Aha! Thank you

The issue was indeed solved for me by replacing the Vel-structs with a local Velocity-component and replacing each instance of the KinematicBundle with inserting the CollisionShape and CollisionLayer components.

I'm leaving this here for future reference in case anyone else – like me – failed to notice that KinematicBundle has a Vel-component or did not understand entities with Vel are eligible continuous collision solving 🙈

Havegum avatar Mar 15 '22 15:03 Havegum

yeah my continuous solver is a bit fragile currently

RustyStriker avatar Mar 16 '22 07:03 RustyStriker