I’m making a Halloween game using Cocos2dx v3.17.2 and I have it ready for upload to the stores.
I’m using Chipmunk built in physics created using PhysicsEditor, each object has different restitution value and everything is working like a charm in iOS.
The game is as shown in the picture below. Objects (in yellow) fall from the sky at (0,-300) gravity and you have to move the orange object (pumpkin) to gather the objects. The rest of the items on screen are non dynamic objects that act like some kind of bumpers. The numbers in the picture are the restitution of each object.
I was porting it to Android and I’m encountering a big problem. The physics sometimes work well like in iOS but sometimes they bounce like 20x the bounce that should be.
As I’m using different restitution values, I wasn’t using a fixed preSolve action like solve.setRestitution(0.1f); to avoid these strange bouncing, but even using this, I still have this problem that make the game unplayable on Android…
Does anybody know why is working different than on iOS? How can I solve it? Please any help will be very appreciate!
I use Box2D for physics, so can’t really help with Chipmunk. The only thing I can suggest is trying to update to a newer version of Chimpunk, and also use whatever you can to locate the actual source of the problem, like finding out what values are different between iOS and Android (debug/console output statements etc).
@slackmoehrle I’m using built in physics too, not an external Chipmunk library.
@R101 I wasn’t able to locate the problem. The values of restitution that I’m getting in my onContactPreSolve function when objects collide are the same in both devices (iOS and Android), so I don’t know why is this happening…
The values I’m getting are 0.480000 when the dynamic object (yellow) collides with the green static walls and 0.120000 when the object collides with the pumpkin (orange), and they are always the same values.
I wonder if I will be able to migrate to Box2D just in a few hours, I just need to know how to attach the sprite to the physics bodys and to know which objects are the ones which collide.
Sorry without any sources we cannot know what is different.
Or maybe a movie about the different behavior?
Does the cpptest physic example working without different behavior?
Maybe your steps be different…? Some stuff running behind the game?
I enabled debug draw but nothing wrong with that. This is happening with all candy even with circle shapes.
I solved it in the onContactSeparate(), limiting the angular velocity and the velocity to a fixed value.
It should work just like on iOS without having to do anything like this. Its working in this minigame but I had to cancel other minigame because of the same problem. I didn’t find a way to solve it and it’s sad cause I spent a lot of time creating that minigame. I will make a post about it.