I am trying to make a game about balls and using sprite kit with physics body for IOS 7. My problem is about resting objects when contact / collide. Here is my code in didBeginContact
:
[contact.bodyA setVelocity:CGVectorMake(0, 0)];
[contact.bodyB setVelocity:CGVectorMake(0, 0)];
contact.bodyA.resting = YES;
contact.bodyB.resting = YES;
Actually contact.bodyA
is already resting but I just set it to make sure both objects are set to resting. The problem is, balls are not touching to each other even if I set contact.bodyA(or B).resting = YES
.
This is what I want:
http://i.stack.imgur.com/p8JTk.png
This is what happening sometimes:
http://i.stack.imgur.com/LWORO.png
As you can see in second picture, the blue ball is a bit far from other balls. Is there any other way to magnet the ball at contact point always?