Hi. I have some bug with contact listener: endContact called more times, than beginContact for two dynamic bodies collision. For example, beginContact called one time, but endContact called three and more times. It's all right when dynamic body collides with static or kinematic body
Contact listener problems
Bugs, Requests, and FeedbackI think the problem is on line 614 of your source code, take a look there.
Of course, I'm just kidding 🙂 Can you give a small example of this that somebody can look at, or to reproduce the problem themselves? Otherwise it's impossible to do anything.
Of course, I'm just kidding 🙂 Can you give a small example of this that somebody can look at, or to reproduce the problem themselves? Otherwise it's impossible to do anything.
https://www.iforce2d.net/b2dtut/jumpability
This is pretty common for any jumping. I believe the best way to put it is when two bodies hit, they aren't just hitting once but multiple times. The best way to detect whether somethings touching or not isn't a boolean but an integer
This isn't a bug but rather a feature in that when two bodies hit, they hit eachother multiple times naturally.
This is pretty common for any jumping. I believe the best way to put it is when two bodies hit, they aren't just hitting once but multiple times. The best way to detect whether somethings touching or not isn't a boolean but an integer
Code:
int foot_contacts = 0;
void beginContact(Contact contact){
foot_contacts++;
}
void endContact(Contact contact){
foot_contacts--;
}
void beginContact(Contact contact){
foot_contacts++;
}
void endContact(Contact contact){
foot_contacts--;
}
This isn't a bug but rather a feature in that when two bodies hit, they hit eachother multiple times naturally.
Thanks to all. irresistible force, small examlpe of the code you can see in the third post 😀
S986S, you are right, i need it for jumping. I read this article, and i count contacts. My code is similar to your code. And it works excelent when my character (dynamic body) collides with static environment (static bodies) or with moving platforms (kinematic bodies). But when it collides with other dynamic bodies foot_contacts become negative, because endContact called more times, then beginContact.
P.S. sorry for my english language, it is not native for me:)
S986S, you are right, i need it for jumping. I read this article, and i count contacts. My code is similar to your code. And it works excelent when my character (dynamic body) collides with static environment (static bodies) or with moving platforms (kinematic bodies). But when it collides with other dynamic bodies foot_contacts become negative, because endContact called more times, then beginContact.
P.S. sorry for my english language, it is not native for me:)
Are you using the original C++ version or a port to another language? It would be a pretty bad bug if what you say actually occurs. If you can make a small reproduction case I will take a look at it.
Original thread: https://box2d.org/forum/viewtopic.php?t=9715