• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
BennettSteele

Simply Grasping Collisions and Contacts

18 posts in this topic

I have spent numerous hours and days trying to grasp these... Starting with a wonderful idea or theory, but then i start to think of scenarios for that theory, and it falls apart. I know it is abstract, and I can see how it would be that way... but I cant figure out how to calculate simply when 2 boxes are touching. I have a lot of graph paper with theorems and ideas, but i only have one uploaded since it was the most concrete, but still didnt work out... (in attachments)

So im wondering... can simple 2D box collisions be simple? Or am I taking it too lightly?
0

Share this post


Link to post
Share on other sites
I'm not sure from your drawing, are you trying to compute box/box collision onlu from the corners and velocity rays ?
have you considered the fact that your collider can be a smaller object than the box ?
you need to consider edges crossing as well.
also, intersection, collisions, and response are three different things.
intersection doesn't consider movement, "collision" suggests a sweeping volume, response is "physics"
maybe that'll lead you to a more structured thinking :)
0

Share this post


Link to post
Share on other sites
Yeah, thats one of the reasons why it fell apart. I know everything but the process of actually detecting collisions (which is not much). I have been trying to basically memorize and understand completely how one would go about collision resolution. I know there are a lot of pages on how to detect them, like Hodgman's link, but I am talking about a more in-depth, explanation of every single little step there is and why that step is there. I just got done reading this book:
[url="http://www.amazon.com/Physics-Engine-Development-Second-Edition/dp/0123819768"]http://www.amazon.com/Physics-Engine-Development-Second-Edition/dp/0123819768[/url]

But it did not explain why some of the steps were in there, but rather just described what it did. If there are any resources on collision detection and that fit what I stated before, please post. :P

Also, I hope I am not the only one having trouble with this. Hopefully this can help anyone else who too has the same problems. :)
0

Share this post


Link to post
Share on other sites
Also, my drawing shows my thinking of how to detect collisions or contacts by checking velocities. If you want to know more about it, please ask. It is my best "Theory" (I guess you could call it), because none of my other ones have lived to make it too code. But it does not work, because smaller object than it wont collide.
0

Share this post


Link to post
Share on other sites
I gather from your diagrams that you're talking about collisions between 2D axis-aligned boxes moving in any direction? It sounds like you understand a fair bit of it from reading papers etc. Are the specific areas that you're stuck on?
0

Share this post


Link to post
Share on other sites
Basically understanding why the steps of collision detection need to be there. And yes, it is 2D. But i plan on also using it for my 3D game since it wont need rotation physics. But im stuck on the steps of collision detection.
0

Share this post


Link to post
Share on other sites
Whether it's complex depends a lot upon what your expectations are. Here's a few examples:

1. Detect whether two boxes are intersecting at a specific moment of time: Easy.
intersecting = (b1.left < b2.right) and (b1.right > b2.left) and (b1.top < b2.bottom) and (b1.bottom > b2.top)
2. Detect whether two boxes may have collided (e.g. swept out the same area within delta time d): Medium
intersecting = does polygon swept out by b1 within time d intersect with polygon swept out by b2 within time d
3. Detect whether two boxes did collide (excludes swept out same area but missed): Medium-hard
intersecting = find a time t such that the conditions in 1 are all met, taking velocity into account. Umm... take a look at this:
[url="http://en.wikipedia.org/wiki/System_of_linear_equations"]http://en.wikipedia....inear_equations[/url]

Those may not be the best options, just what occurred to me. Generally it is assumed that the timestep and speed of objects is such that you wouldn't need to go further than step 2. If objects move that fast or are that small it is hard for a player to interact with them. Edited by jefferytitan
0

Share this post


Link to post
Share on other sites
My expectation, or what I need is an impulse based collision system, and possibly later include rotation. But as it seems, I really suck at collision programming. :-\

Mainly I am hoping to come across a nice article on basic collision resolution, that describes each step and why that step is needed. For some reason, I cant utilize a strategy without knowing why it is...
0

Share this post


Link to post
Share on other sites
No need to put yourself down yet; there's always time later. [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]

I'm not aware of such an article off the top of my head (not to say it doesn't exist). Just for starters, did my post on how to detect if there was a collision make sense? I can explain in more detail.
0

Share this post


Link to post
Share on other sites
Yeah, those make complete sense, and I know exactly know why it is like that: because you are checking each axis. But something more complex, like... having rigid-body physics... :-\

Im looking forward to something like that. Thats why I read that book about it, but it did not explain it in such a matter that helped me completely understand it.
0

Share this post


Link to post
Share on other sites
There are two major problems:[list=1]
[*]The physics of arbitrary collisions without rotation isn't natural, so requires assumptions from the programmer.
[*]Single collisions are easy(ish), multiple simultaneous collisions are hard. Proper physics engines have solvers that take many iterations to try and resolve the many constraint violations caused by solving the collisions locally. So for example, if blocks A, B and C are in a line and hit on the end by block D, firstly momentum will be transferred to block C. But that causes a collision with block B. Solving that causes a collision with block A. If block A is "free" it can then shoot off like a Newton's Cradle. If block A is pressed up against a wall, then this needs to be propagated all the way back to D.
[/list]
Basically I'm saying that if you're trying to do single collisions, that's cool and probably easy. Anything else... is really a hard problem, so no wonder it's confusing you.
1

Share this post


Link to post
Share on other sites
XD Yep. And since this is my first time doing everything, its a lot harder. [img]http://public.gamedev.net//public/style_emoticons/default/laugh.png[/img]

I bet if like the way i have come along, which is to start as simple as possible, then progress to harder things, i might be able to learn something. But if anyone has any links or tutorials even, it would be greatly appreciated. [img]http://public.gamedev.net//public/style_emoticons/default/happy.png[/img]
0

Share this post


Link to post
Share on other sites
I appreciate your struggle, it can definitely be a lot to wrap your head around (I don't really feel like I truly understand anything about collision yet either).

One resource that you might find edifying is Paul Firth's excellent tutorial, which covers a lot of material: [url="http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/"]http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/[/url]

Personally, one concept which has really helped me better understand collision is Minkowski sums (or differences); for your example of two axis-aligned rectangles, imagine reducing the width and height of box A to 0 (so that the box becomes a point) while simultaneously increasing the width and height of box B by the same amount -- you now have a point A and a box B, which is simpler to visualize/think about, and completely equivalent to the original problem.

Separating collision detection (geometric queries) from how you use the results (collision resolution/solving) can also help make the problem easier to understand. In terms of solving a set of constraints, this is another great overview to start with: [url="http://www.wildbunny.co.uk/blog/2011/04/06/physics-engines-for-dummies/"]http://www.wildbunny.co.uk/blog/2011/04/06/physics-engines-for-dummies/[/url]
2

Share this post


Link to post
Share on other sites
Thanks for posting those links Raigan :)

The OP might also appreciate this article, in which I describe generating the full contact set (among many other things) from the closest feature pairs returned by SAT, or minkowski difference:

[url="http://www.wildbunny.co.uk/blog/2011/06/07/how-to-make-angry-birds-part-2/"]http://www.wildbunny.co.uk/blog/2011/06/07/how-to-make-angry-birds-part-2/[/url]

Just part of implementing a physics engine capable of playing angry birds - hence the title :)

Cheers, Paul.
1

Share this post


Link to post
Share on other sites
Thanks! :P

These look really good, I plan on reading them all tonight. It looks really well made, too. :)
0

Share this post


Link to post
Share on other sites
So im doing some testing, and got point-box collisions working well. although since the game runs slow sometimes, the dots will pass through walls... but i can fix that.

[color=#666666][size=2][background=transparent]
[size=3][background=transparent][url="http://youtu.be/g0cuql1X0Ps"]http://youtu.be/g0cuql1X0Ps[/url][/background][/size][/background][/size][/color]

But it runs fine regularly... and im hoping to move on to some other different collisions...
0

Share this post


Link to post
Share on other sites
well for point to box you can specially design a "closer distance contact" function to avoid passing through boxes.
(raycasting) this function is made by solving the system made of the equations of a line (your ray) and the planes of the boxes.
in this case you would have implemented "swept collision".
also, you need to run your physics/collision loop in a fixed time step.
also, an idea for later, some engines does not run the collision detection at every simulation step.
0

Share this post


Link to post
Share on other sites
Well, since it it tile based, it checks for collisions each time it crosses over to another block. it is slow because i have never wanted to take the time to make it more efficient, and im using fraps. :P

Since it uses it's velocity to check for the next box, when it is slow it will check far away. if you use +1 to its position, it will bounce when 1 unit away. if you use just its position, it will get stuck. :-\
0

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  
Followers 0