• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

How can I define a custom collision mask?

B

Bonny Fernandes

Guest
I was wondering if i could define a collision mask where i can define the points of the edges of the mask. For example: if i give 4 points, i should have a rectangular mask. I am drawing a custom polygon in my game and it changes during gameplay which is why i cant just use a precise mask.
 

zbox

Member
GMC Elder
One way of doing this - Although not the fastest or most precise but I'm not sure if there is another way to do it in GM:

Draw the polygon to a surface, convert the surface to a sprite with precise collisions, and set that sprite as the collision mask.
 

Joe Ellis

Member
One way of doing this - Although not the fastest or most precise but I'm not sure if there is another way to do it in GM:

Draw the polygon to a surface, convert the surface to a sprite with precise collisions, and set that sprite as the collision mask.
That would definitely work but is slow as hell, the only other ways I can think of which would be moderate speed is using collision lines (1 for each edge of the polygon) or using rectangle_in_triangle (the rectangle being the bounding box of other instances) and the polygon being split into triangles,
there are alot of ways you can manually calculate the collisions aswell if you're willing to spend the time learning about them.
 
Top