• 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!

GameMaker Most common ways to use colision mask?

Suzaku

Member
I want to make a colision mask in Gamemaker Studio 2, to my moving character and I ve been looking the internet to find some ways to use colision mask properly, here is what I found so far:

1 way: Just using the automatic colision mask that gamemaker offers. This seems to be very limited and it caused my character to stuck in the wall if flipped, after some tests I figured out it was because the size numbers were odd numbers. Also is that common to happen?

2 way: Drawing a custom rectangle sprite to set it as the main sprite of my character and then just drawing the necessary sprites on its draw event. Didnt try this yet.

3 way: Drawing a custom rectangle sprite to set it as the colision mask of my character. This seem to be the way to go..

What do you think? Any advice? Thank you very much.
 

mimusic

Member
When using GM's provided collision, I've always preferred to have a single rectangular mask per object, and then just set the collision mask to that sprite. This lets me set collision ranges without having to worry about inconsistencies, cuz it's always checked against the same masks. Works well in games where basically all collisions are based on rectangles, like a Super Mario game.

Though options 2 and 3 are similar, 3 is safer. Much less likely to accidentally swap the sprite (and thus the mask) when using option 3.
 

Relic

Member
1) yep. If you adjust image_xscale then the assigned mask, whether default sprite msk or collision mask, also flips. The flipping occurs along the left edge of a pixel so even numbers are required so that the same number of pixels are on both sides of the middle.
 

Suzaku

Member
1) yep. If you adjust image_xscale then the assigned mask, whether default sprite msk or collision mask, also flips. The flipping occurs along the left edge of a pixel so even numbers are required so that the same number of pixels are on both sides of the middle.
Damn I wasted my whole day to discover that by myself. I ll remember that from now on. Very good explanation.


When using GM's provided collision, I've always preferred to have a single rectangular mask per object, and then just set the collision mask to that sprite. This lets me set collision ranges without having to worry about inconsistencies, cuz it's always checked against the same masks. Works well in games where basically all collisions are based on rectangles, like a Super Mario game.

Though options 2 and 3 are similar, 3 is safer. Much less likely to accidentally swap the sprite (and thus the mask) when using option 3.
Thank you, you guys are awesome.
 

TheouAegis

Member
Damn I wasted my whole day to discover that by myself. I ll remember that from now on. Very good explanation.
Follow-up on that.

You can give a sprite any type of rectangular mask you want inside its properties; it doesn't have to be a full mask and in most cases it shouldn't be. Aesthetically, the mask should cover the torso and feet; head and arms are often not desireable. The ONLY requirements for a rectangular mask to work with image_xscale is that 1) the mask itself be an even width, meaning if the left bound value is an even number, the right bound must be an odd number or vice-versa, and 2) the origin of the sprite must be in the horizontal center of the mask, not the sprite.
 
Top