Announcement

Collapse
No announcement yet.

CircleCollider2D manual check against RectangleF

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • CircleCollider2D manual check against RectangleF

    Having an issue with CircleCollider2D. I'll first say I have live entities moving around and colliding just fine, but going beyond engine-facilitated physics, I'm performing some manual collision checks.

    In my particular use, I'm just trying to translate 2D collider shapes into TileGrid blockers. I thought I'd iterate over each grid, formulate it's rectangle, and check if it Intersects my collider shape, a circle. I realize this is also probably wasteful if grid tiles are small, and I'll ultimately use Collider.Contains for each corner of a grid rectangle, as Intersects wouldn't catch rectangles fully within a collider shape (I presume).

    A Contains check returns a result as expected, but I would expect if any edge of my rectangle intersects any edge of my collider circle, I should get a True result.

    I'll attach an image of my debug lines and my simplified *.cs file code demonstration. Tiny rect at {1,1} is my manual check. Circle is my collider, and of course large rect is my Entity debug bounds.

    I have yet to check other collider shapes as well, but should I expect Intersect to perform in this manner?
    Attached Files
Working...
X