Jump to content
  • Advertisement
Sign in to follow this  
ntwiles

Collision Bounds

This topic is 2601 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

Hi guys, I'm new to the forums and I have a question about determining rectangle bounds for collision checking.

Currently the way I'm doing it is creating a bounding box with the dimensions of the current sprite an object is using, which may have different heights and widths depending on its state. The issue I see with this is if an object suddenly changes to a sprite width a greater width, it could be pushed inside a second object it was previously only adjacent to. The way I see it the two solutions would be to either to keep all my sprites at the same height and width, or to keep my bounding boxes always at the same height and width ignoring the sprite size. Neither of these options sound very appealing so I'm wary about trying either. I'm self taught and very amateur so I would love to hear how other people go about doing this. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
You have a couple of options:

  • always overestimate the bounding box size, so that even if the sprite increases its size, it will still be fully inside, or only partially outside the physical bounding box so that it does not look distracting even if sprites slightly overlap.
  • Disallow the game mechanic or visual effect altogether that causes sprites to resize.
  • Link the game mechanic/visual effect that resizes the sprite to the physics subsystem and disallow the sprite from changing size if it would result in an overlap. I.e. only allow sprite resize if it has free room for it.
  • Link the sprite resizing to the physics subsystem, and perform a physical reaction to when the sprite increases the size and collides, e.g. push its position away from the obstacle so that it does not penetrate any more, or give it a velocity away from the obstacle to resolve the penetration (or do both, i.e. adjust the position *and* velocity at the same time).


Share this post


Link to post
Share on other sites
Sign in to follow this  

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