Collision Bounds

Started by
0 comments, last by clb 12 years, 5 months ago
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!
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).



This topic is closed to new replies.

Advertisement