Collision checking on angled sprite not working RRS feed

  • Question

  • User305631 posted

    I have a entities that goes from the top left to the bottom right. The entities have a sprite that is just a black block. When the block collides with another block I set its velocity to 0. When checking collisions for the sprite it works fine but when I set the sprites rotation or use CCRotateBy the collision still stops where it would have had it not been angled. I am using the BoundingBoxTransformedToWorld to check for intersection. Why is this not working?

    public bool Intersects(Vehicle other) { return this.sprite.BoundingBoxTransformedToWorld.IntersectsRect(other.sprite.BoundingBoxTransformedToWorld); }

    Sunday, April 2, 2017 11:13 PM


  • User305631 posted

    Nevermind, after doing some research it turns out that rotating a sprite creates a bounding box with a maxX,maxY,minX,minY so it essentials draws a bigger box with 0 rotation around the rotated rectangle

    Looking into box2d it looks like they have an IsTouching() method on b2Contact but I can't figure out an easy way to just use that for collisions yet.

    Is this really such a strange feature to expect?

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, April 7, 2017 10:27 PM