Jump to content
  • Advertisement


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


Need help with collision detection of like items

This topic is 5711 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 am able to use collision detection to tell if one item runs into another item of a different type, but for some reason I''m having a difficult time figuring out some code for, say for example, a sprite that I make multiple copies of and they continually overlap one another. Sound confusing? What should I do to keep the one item from overlapping with the other copies of that same item? I''ll try to make it a little clearer- If an enemy runs into a player character, the collision code works fine. But, say I have 5 copies of the same enemy, and they run into each other, the same code doesn''t work for them and they just keep on overlapping one another. Can someone ease my headache a bit? Thank you.

Share this post

Link to post
Share on other sites
Could you just give each character or drawn item an "isSolid" property in your struct? That way, when you do your collision detection, just check to see if an item isSolid to see if they can overlap or not.

Share this post

Link to post
Share on other sites
It sounds like how you handle collisions between the first two items doesn't propagate correctly to avoid them overlapping any of the rest of the group when those objects respond to their collisions.

What is your algorithm? What are the steps you take?

For instance, my idea of the ideal billiard game goes like this:

* Detect the first collision
* Move everything up to that point
* Apply the results of the collision

Repeat until the frame time is consumed or no collisions occur

This keeps any two billiards from overlapping no matter what happens in the playfield. But this would not work well for a game that has many objects (the algorithm is slow), unless a quadtree is used to separate the objects so that fewer collisions are detected for. It also helps maintain algebraic accuracy so that it actually behaves as expected like a billiard game. But that isn't necessary for a game where creatures are colliding.

Still, when you are done handling the collision between two objects, you don't want how you handle later collisions to cause those objects to overlap the ones you handled before and left behind in the loop.

If you can show us what you're doing, maybe we can tell you what's going wrong.

[edited by - Waverider on April 21, 2003 11:37:41 AM]

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!