Tutorial: Newton's Cradle

I spent most of the day implementing Newton’s Cradle using Corona SDK.

Seems straight forward enough, but for some reason the impacting force was not passed through the spheres but rather divided among them leading to some really odd physical effects.

Some digging revealed that this is not a bug in Corona SDK but rather in Box2D and actually most physics engines ever created.
So Cocos2D is just as affected as any other (readily available) gaming engine using standard physics.

The problem boils down to the fact that most engines can’t handle the “already touching” state correctly and then get tangled up in trying to calculate countless collisions between the spheres.

After some experimenting and raiding the Box2D, Cocos2D and several physics forums (gah…) I found a solution (several small ones working together actually) that gives a fairly accurate Newton’s Cradle in Box2D.
Thought I’d share them with you so you don’t have to repeat reading through physics documentation. :slight_smile:

–> http://blog.reflare.com/post/3165513678/implementing-newtons-cradle-box2d-corona-sdk [import]uid: 10292 topic_id: 6203 reply_id: 306203[/import]

Nice work. Thanks for sharing. [import]uid: 3953 topic_id: 6203 reply_id: 21347[/import]