Hi everyone,
Total newcomer in this forum. I first want to congratulate and thank Erin for creating such an amazing library and allowing to use it free of charge. I've followed the project for quite a while but never got the time to actually put myself into it, but now I'm decided to actually do something with Box2D. As for my level of C++, it is all self-taught and I've been practicing for a few years now, so my code may not be perfectly clean but it generally works. All advice concerning the way I code things are welcome.
Now, I'll explain my situation. I am currently trying to build a platformer-like engine with Box2D. I'm using a modified version of the Testbed for displaying the shapes (just modified it so there is no bar on the right). So far I've created a static body for the ground with multiple shapes as a test level, and a dynamic body for my test character. I've used and updated some code from the old wiki to create an "Object" class for my bodies and buffer all b2Contacts for my character.
At first, I was making my character move horizontally, but it was very bouncy when I tried to move up or down a slope. So as to solve this problem, I now use the contact information to look for all contacts with the ground (localNormal.y>0, with slope<45°) and get an average normal. I use this normal to determine the direction the character must follow to move left or right. It works well with a flat ground or for going down a slope, but the character still tends to bounce a lot when going upwards. I've set the friction and restitution both to 0, and the iterations to 10, but it doesn't change anything.
Here's the source code, hoping that someone could help me for this matter :
I hope I was clear, and thanks in advance.
Total newcomer in this forum. I first want to congratulate and thank Erin for creating such an amazing library and allowing to use it free of charge. I've followed the project for quite a while but never got the time to actually put myself into it, but now I'm decided to actually do something with Box2D. As for my level of C++, it is all self-taught and I've been practicing for a few years now, so my code may not be perfectly clean but it generally works. All advice concerning the way I code things are welcome.
Now, I'll explain my situation. I am currently trying to build a platformer-like engine with Box2D. I'm using a modified version of the Testbed for displaying the shapes (just modified it so there is no bar on the right). So far I've created a static body for the ground with multiple shapes as a test level, and a dynamic body for my test character. I've used and updated some code from the old wiki to create an "Object" class for my bodies and buffer all b2Contacts for my character.
At first, I was making my character move horizontally, but it was very bouncy when I tried to move up or down a slope. So as to solve this problem, I now use the contact information to look for all contacts with the ground (localNormal.y>0, with slope<45°) and get an average normal. I use this normal to determine the direction the character must follow to move left or right. It works well with a flat ground or for going down a slope, but the character still tends to bounce a lot when going upwards. I've set the friction and restitution both to 0, and the iterations to 10, but it doesn't change anything.
Here's the source code, hoping that someone could help me for this matter :
Code:
edit : Cleared the code as the problem is solved, the code has now changed a lot, and so as not to flood the topic.
I hope I was clear, and thanks in advance.