Bouncing balls

Started by
4 comments, last by Ed Welch 14 years, 4 months ago
Can somebody provide me some good articles on that would help me get started with how bouncy balls would react when bouncing off each other or a wall. I know how to get them bouncing up and down in different directions and how to detect collision between them, but I'm unsure on how they change direction afterwards. For example if I hit a wall, I would guess I could use dot product with the plane normal to somehow change it's direction but I'm not sure; If it hits a wall while being throw up would it's new direction be an exact reflection at the normal? Furthermore I don't know how one ball hitting another might alter both velocities. thanks for any links.
Advertisement
The following thread may be of interest to you, I have been trying to get someone to review it for a few days now.

http://www.gamedev.net/community/forums/topic.asp?topic_id=554643
it appears I was overthinking this - if I have sphere intersect with a plane all I needed to do would reflect the direction velocity vector at the surface normal, then divide velocity by an offset that alters depending on what direction you hit; the same concept as when you hit the floor and bounce you invert the y velocity and weaken it. probably a cheap hack, but you can't tell when looking.
Yea you could just invert the y or the x depending on the position hit.
But I would also still like to know (if anyone wants to explain nicely) how
one would do this with vectors and normals.


regards, A Beginner
Edge cases will show your design flaws in your code!
Visit my site
Visit my FaceBook
Visit my github
If the ball is rotating, it won't bounce according to your rules. If it wasn't rotating, it will be after it bounces on a plane with some angle. I've never programmed this myself, but I have played enough billiards to know these things. :)
Quote:Original post by icethelog
it appears I was overthinking this - if I have sphere intersect with a plane all I needed to do would reflect the direction velocity vector at the surface normal, then divide velocity by an offset that alters depending on what direction you hit; the same concept as when you hit the floor and bounce you invert the y velocity and weaken it. probably a cheap hack, but you can't tell when looking.


Yes, you're right, but if the balls bounce off each other then you will need to do some maths. I found this tutorial very good:
http://www.tonypa.pri.ee/vectors/start.html

This topic is closed to new replies.

Advertisement