collinhover/impactplusplus

collision box, offset and angle/rotation

Closed this issue · 1 comments

So, I have a sword entity. Which has a size of 3x10. The sword itself is 3x10 (the animationSheet)

But when I rotate the entity, the collision box is not rotated nor is it sized up to accommodate.

What should I do?

Collision boxes used to rotate. Truthfully, the box would resize to fit the rotated entity, so not true rotation. The reason impactjs's collisions are so fast is because we can assume everything has an axis aligned bounding box, and AABB intersections are extremely fast. If you start rotating boxes, there is a lot you'd need to change, such as the collision map traces and the touches method.

I removed the rotation because the very small extra precision was not worth the trouble. It did not noticeably affect the gameplay from the user's point. I would set the collision box of your sword to 8 x 8 or something similar to account for the rotation. However, if you absolutely need precise collision boxes, I'd recommend injecting Box2D into your project.