#### Archived

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

# 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.

## 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 on other sites
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 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 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

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
633330
• Total Posts
3011388
• ### Who's Online (See full list)

There are no registered users currently online

×