• 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
ManicPumpkin

Collision detection of many objects (calculation problem)

4 posts in this topic

Hello,

 

currently I think about a problem of one of my projects. The problem is, I generate a world with some objects and a player object, that's able to walk inside this world. The first question I've is how I can detect collisions in a simple way?

 

All of my objects have a bounding box. So I'm able to detect intersections with every game tick between two or more objects. I guess, this is the simplest of all ways, but my problem is now, if I have a world with more than hundred objects? Here a small description ...

 

My idea is, to divide the objects into static and dynamic objects. That means, static objects don't move, like a rock or tree. Dynamic objects are able to move, like a cow or a human NPC's. 

For this moment we only handle static objects and we leave dynamic objects out. I've a rendered view (sight distance of the player) of 12 blocks (means bounding boxes; objects) in one direction. I would render all blocks in any angle around of the player position. Means 12 blocks before, behind, over and under the player. In two dimensions (x and z axis) this are 24 blocks from left to right and 576 blocks on one dimension. I guess, this isn't that much, but if I add the y axis, then I've to render 13.874 blocks. I guess, for collision detection with bounding boxes that would be hard. And to be honest: A view distance of 12 blocks are not really much. So it would be better to increase the distance to 30 or 50 blocks in one direction. But that increases also the calculation problem!

 

The question is, how can I detect collision, with static objects in the world in a good way with many objects? For me, an iteration through all objects to calculate the euclidean distance (which object is the nearest and with which of this objects is a collision possible) seems really hard in cost of calculation?

Is there a good way to calculate this collisions?

 

That is more the simple way to calculate a collision between many static objects and one movable player object, but what if there are some more dynamic objects in the same area like my player object?

 

I would be glad to get some information/resources how to manage this problem in a good way. (-:

Thank you so much!

0

Share this post


Link to post
Share on other sites

Is your world made of blocks/tiles?  It sounds like it might be, if so you could drastically simplify the collision checks by having a map of what object is in what tile. 

 

If it's not, you might want to look into spatial hierarchies, or doing simpler things, like splitting up things into collision 'layers'.  Sort of like your dynamic/static, but perhaps bullets can't collide with one another, so put them on a distinct layer.  

0

Share this post


Link to post
Share on other sites

Have you considered using a physics library such as Bullet? Collision detection / response isn't a simple subject and using an existing solution might save you lots of efforts.

 

Cheers!

1

Share this post


Link to post
Share on other sites

Is your world made of blocks/tiles?  It sounds like it might be, if so you could drastically simplify the collision checks by having a map of what object is in what tile. 

 

If it's not, you might want to look into spatial hierarchies, or doing simpler things, like splitting up things into collision 'layers'.  Sort of like your dynamic/static, but perhaps bullets can't collide with one another, so put them on a distinct layer.  

 

I talked about the bounding box of objects. This bounding boxes are blocks. (-;

But at first, yes, this things are blocks. Later there will be much more complex objects, but I guess, bounding boxes are fine for that, what I plan to program. (;

 

What do you exactly mean with this map? You mean, I've to save all my objects with there coordinates in one hash/array?

Do you have any resources for your ideas?

 

@kauna:

 

I've thought about this, but I want to learn how to solve such problems. In the end, I can use libraries for physics and stuff, but I want to know how is it possible to program that by my own. (-:

0

Share this post


Link to post
Share on other sites

The spatial hash method is a good one to look into for your particular problem.  Basically, what this means is, you divide your worlds into an X by Y grid of cells, and you only check for collisions between objects within the same cell.

 

Here's a link  to an article discussing it.

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