bevy_physimple
bevy_physimple copied to clipboard
Square sensor only detects overlap at edges of another square
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:
The sensor detects the red square and turns yellow when the near edges are close:
However, as the blue square moves further, the sensor no longer detects the red square:
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.
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)
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 🙈
yeah my continuous solver is a bit fragile currently