A Flash Developer Resource Site

# Thread: another stinking ball collision problem

1. ## another stinking ball collision problem

i realize this is a common problem, but while ive seen many posts on the subject, no one seems to be addressing the major problem as i see it.

detecting collision is no sweat. even the physics of the balls bouncing off one another isnt so bad ( found a great explanation www.plasmaphysics.org.uk/print/collision.htm )

the real problem is that the balls are never exactly twice the radius apart (they overlap). this makes for some unnatural effects like the balls jiggling together a few times before separating. to stop this, i tried preventing two balls that have just collided with colliding again for a while. unfortunately, there remains some lingering weirdness, like sling-shoting.

i think the elastic collision has to be calculated at the point mid-frame when the balls are exactly 2r apart, but i dont know how to do this with 2 objects moving at arbitrary velocities.

does anyone have a definitive solution for just this part of ball collision?

thanks

2. One way to overcome that nasty jiggling is if there is a positive collision detection of two balls having their centres less than twice the radii (i.e. overlapping), then place them at EXACTLY twice the radii apart (ie. just touching) BEFORE you calculate the "bouncing angles". This does require a bit of trig to determine how far to move each ball apart on the same line of action that they were travelling on.......but just off the top of my head an easier way could be.....a multiplication factor of each (-ve) x and y velocity component - this factor being the ratio of (half overlap amount/radii)....I think - but you get the idea.

Anyway its sunday morning and second breakfast awaits..

swills

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap