Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add convenience methods for determining if collisions are starting or stopping #529

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ndarilek
Copy link

@ndarilek ndarilek commented Oct 6, 2024

Objective

It can be tricky to match and handle all of an entity's collision states in a single event loop. I routinely find myself writing code like this:

    for Collision(contacts)in events.read() {
        let started = contacts.during_current_frame && !contacts.during_previous_frame;
        let stopped = !contacts.during_current_frame && contacts.during_previous_frame;
        if started {
        } else if stopped {
        }

Solution

Add Contacts::collision_started and Contacts::collision_stopped to more conveniently check these conditions.

Changelog

Added

  • Added Contacts::collision_started and Contacts::collision_stopped for more conveniently checking if a collision just started or stopped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant