Archived

This topic is now archived and is closed to further replies.

Endemoniada

Unusual Circle-Circle Collision Response

Recommended Posts

Hi guys, Please picture an Arkanoid/Breakout type game but where the paddle is a circle (it''s 2D so no spheres), you can move the paddle left and right as usual. When the ball hits the circle paddle the ball''s direction becomes the normal at the collision point, just the vector from the paddle center to the ball center, no fancy physics involved. The problem is that if I move the paddle left (or right) and slam it into the ball and keep moving the paddle left (or right) the ball sticks to the paddle until I stop moving it. I guess what''s happening is that after they collide the first time they collide again the next frame because I moved the paddle between frames. I''m using relative velocities (ball.velocity-paddle.velocity) for the calculations. I''d like to push the ball away with the paddle, and also make it so that the harder the paddle hits the ball (i.e. the larger the paddle''s velocity magnitude is) the faster the ball will travel after the collision. Do I have to add physics ? I need some guidance. Thanks.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Physics is just the way objects interact. You already have your own basic physics system implemented (it just happens to not be exactly like real physics). You don''t need to implement any sort of realistic physics, you can make the objects interact however you like. Now to make the ball travel faster after a hard collision, you''ll want to make the ball''s resulting velocity relate in some way to the ball''s old velocity (if the ball is moving faster, it will bounce off faster) and the paddle''s velocity (a fast paddle will make the ball go faster). You''ll want to calculate the paddle''s speed relative to the ball, to determine if the collision will slow down or speed up the ball. You might also want a minimum and maximum speed limit, to keep the game under control.

Share this post


Link to post
Share on other sites
Hi guys,

Thanks for the help.

I tried a few things and it still isn''t right. Here is what''s happening:

The moving paddle hits the ball causing a collision, I set the ball and paddle to their respective positions at the time of the collision (so they just touch) and set the ball''s new direction; then the frame gets rendered and goes back into the collision detection/move objects function.

But since the paddle was still moving (because the user was still moving the mouse between frames) it hits the ball again before the ball gets away in it''s new direction.

A pretty fast ball moves at 1,000 pixels per second, 2,000 is really fast, almost ridiculously so. However, the paddle can move at 8,000 pixels per second (I capped it at that, anything slower is not responsive.) So the ball has to move away from the paddle faster than that after it gets hit to prevent it from "sticking."

I tried giving the ball a boost for one second after it got hit and so far that''s my best solution but it doesn''t feel right.

Any ideas ?

Thanks.

Share this post


Link to post
Share on other sites
quote:
Original post by Endemoniada
Hi guys,

Thanks for the help.

I tried a few things and it still isn''t right. Here is what''s happening:

The moving paddle hits the ball causing a collision, I set the ball and paddle to their respective positions at the time of the collision (so they just touch) and set the ball''s new direction; then the frame gets rendered and goes back into the collision detection/move objects function.

But since the paddle was still moving (because the user was still moving the mouse between frames) it hits the ball again before the ball gets away in it''s new direction.

A pretty fast ball moves at 1,000 pixels per second, 2,000 is really fast, almost ridiculously so. However, the paddle can move at 8,000 pixels per second (I capped it at that, anything slower is not responsive.) So the ball has to move away from the paddle faster than that after it gets hit to prevent it from "sticking."

I tried giving the ball a boost for one second after it got hit and so far that''s my best solution but it doesn''t feel right.

Any ideas ?

Thanks.



ball again before the ball gets away in it''s new direction.

Let''s call that direction bv. This could be represented by a vector. The paddle should also have a velocity vector, pv. After you find out bv (making it bounce), just do bv+=pv. That way, the paddle''s momentum is transferred to the ball, just like in real life. That way, the faster you move the paddle, the faster the ball will move.

That''s how I''m gonna do it in my air hockey game.

Share this post


Link to post
Share on other sites