Sign in to follow this  
origil

Real-Time in an unreal world...

Recommended Posts

origil    134
This is an issue that had me shaking up 4 different search engines including myself for about 2 weeks now... I just don't get it. I'm trying to get quality collision detection in a breakout game but still... I know how to predict a collision between 2 circles and how to tell if there's a collision between a circle and a line. But I can't get to predict a collision between a circle and a line... Thinking it out again, maybe the game wouldn't need to predict collision in such fashion because if I'm using time delta movement and I manage to keep my game at 50 fps [at minimum] then in order for an object to skip collision it'll have to be moving at more than 50 pixels per second and that'd still be far from missing collisions. Is this approach correct? Should I consider medical help? Is there an answer to this question that might bring a smile to my face or is it going to fund my future psychologist's bank account? Thanks in advance, Ori

Share this post


Link to post
Share on other sites
Dmytry    1151
Collision of moving circle with line is simple. You need to find when distance between circle center and line get smaller than radius of circle. This is the same as finding when circle center enters the area around line where points is closer to line than r.

To get idea, draw line on paper, and draw circles around end points of line, and connect circles tangentially so you get kinda capsule-like shape. All points outside of this shape is further away from line than radius, and all points inside are closer.
The circle is colliding with line when circle's center enters the "capsule". So to predict collision of circle with line you need to intersect circle center's path with "capsule". To do that you only need to compute line-circle intersection for rounded ends of "capsule" and line-line intersection for sides of "capsule".

(as about practical, i think in the game such as breakout you can aswell do several intersection checks per frame (and make it run at 50 fps atleast) so it'll be accurate even for really fast ball. But then it is probably more interesting to do collisions right...)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this