Jump to content
  • Advertisement

Archived

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

Rappler

Speedy 2D Collision Detection

This topic is 6718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m trying to detect collisions between an indefinate number of entities within my world''s space. Is there a faster way to detect collisions than sectorizing the game world and testing for collisions in each individual sector? Say if the world is 6400x6400 pixels and I break it into 320x320 sectors and keep track of the entities in each sector and test them against each other. There''s gotta be a better way than this, but the methods escape me right now... "The Gates of Pearl have turned to gold, it seems you've lost your way."

Share this post


Link to post
Share on other sites
Advertisement
I''m not an expert but you should limit it to certain sectors rather than the whole world space (which would probably take alot of time)... and then also if you''re using loops find a way to limit down the collisions by making sure you only tested the object once... like in a loop you''d check sprite1 with sprite2 and then eventually it would get to doing sprite2 with sprite1, so you have to find a way to mark which collisions have already been tested... anyways i hope this gives ya some ideas...

-Keith Weatherby II
Also known as Uhfgood
uhfgood@artoo.net

Share this post


Link to post
Share on other sites
another thing you might want to notice is this: if you do the sector thing, you need to watch out for instances like this:
+----+-----+
/1 3/4 6/
/ 2 / 5 /
+----+-----+
you can see that obj''s 2 and 3 are colliding, and so are 5 & 6.
but what about 3 & 4? if you simply check collisions inside each sector, you won''t catch ALL of them, cuz some will be collisions on the insides of two different sectors, like 3 & 4, they are colliding, but they aren''t in the same sector, so you won''t test them against each other.
farmersckn

Sometimes even chickens need to eat... Don't bang your head against a wall just to enjoy the good feeling when you stop.

Share this post


Link to post
Share on other sites
Bust it up into a <self censored> load of little sectors;
check for collision in the current & the 8 adject sectors (assuming you use rectangles)

just an idea, i havent done much cd yet

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!