Page 1 of 1

Can you create irregular polygons for collision masks?

PostPosted: Sun 18 Jun 2017, 10:23
by ThePaperComet
Is there a way to create a collision mask that has indents?

Re: Can you create irregular polygons for collision masks?

PostPosted: Sun 18 Jun 2017, 15:52
by Lizard-13
Each collision mask has to be a convex polygon (any number of vertices), but you can have multiple collision masks, so you can simulate any complex shape (even concave ones) ;)
You can't do it:
Collision_Mask_0.png
Collision_Mask_0.png (41.19 KiB) Viewed 444 times

But you can do it:
Collision_Mask_1.png
Collision_Mask_1.png (29.83 KiB) Viewed 444 times


:!: Take into account that increasing the number of vertices and collision masks reduce the performace per collision test, specially in HTML5, but I have never tested it though...

Re: Can you create irregular polygons for collision masks?

PostPosted: Tue 20 Jun 2017, 12:38
by ThePaperComet
Ah okay, great. Does it matter if they overlap? (trying to minimize potential missed collisions).

Re: Can you create irregular polygons for collision masks?

PostPosted: Tue 20 Jun 2017, 15:03
by Lizard-13
No, GD doesn't check overlaps with the object itself :)