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

Detect when a collision just started/ended? #57

Open
grunkgrunk opened this issue Jul 26, 2021 · 3 comments
Open

Detect when a collision just started/ended? #57

grunkgrunk opened this issue Jul 26, 2021 · 3 comments

Comments

@grunkgrunk
Copy link

Hey! A lot of game engines have callback functions like OnCollisionEnter and OnCollisionExit that allows running some code just when a collision starts/ends. Now I realize that collision callbacks are not used in this library. I'm wondering if this kind of behavior is supported somehow (without using callbacks) or if it's currently up to the user to implement this? If not, would it be of any interest to have this kind of feature or is it out of scope for the project? I would love to try and submit a pull request and write some documentation for it as well :)) I hope this is the right place to ask these sorts of questions.
Btw, I really appreciate and enjoy using this library!
All the best

@flamendless
Copy link

Hi, you can easily have such behavior by using a flag. If there's a collision and the flag is false, that means thats an on_enter collision, then set the flag to true. then when theres no more collision and if the flag was set, set that to false and then that's on_leave collision.

@grunkgrunk
Copy link
Author

Jup, I guess I had something like that in mind too. You would just add that property to the collision objects returned by for example move, right? :)

@flamendless
Copy link

flamendless commented Jul 26, 2021

You would add that to the table you pass into bump as body yes.

doing check or move returns the tables that have collision so yes you can modify that

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

No branches or pull requests

2 participants