• 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 precise collision transperancy threshold

Z

zendraw

Guest
if you rise the threshold on the transperancy, in precise collision checking, does that ease the burden on collision checking?
 

TsukaYuriko

☄️
Forum Staff
Moderator
"ease the burden" as in "increase performance"? You could test this easily and accurately by using the profiler while having two instances, one with a higher threshold, check for collisions.
 
The threshold just determines how much alpha a pixel needs to have before it is considered a "solid" pixel.

If you have semi-transparent pixels, raising the threshold above a certain amount will cause them to not be included in the sprite mask. Which means less pixels need to be checked when a collision of the bounding boxes is detected.

If you only have pixels that are either fully transparent (alpha = 0) or fully solid ( alpha = 1) then changing the threshold will not make any difference.

If you have a bunch of pixels in your sprite that have, for example, and alpha of 0.5, and you raise the threshold above that value, they will not be included in the mask, which will give faster collision checking in theory. You can visually check this by watching the collision mask preview window for your sprite as you change the threshold value. If there are semi-transparent pixels, you can see the mask shape and size change when you alter the threshold.

So in theory, altering the threshold could yield performance benefits. It's definitely worth testing however, as @TsukaYuriko said, to see how it affects your game.

You can read a detailed description in this blog article: https://www.yoyogames.com/blog/32/the-hazards-of-precise-collision-detection

It's from 2013 but I believe its still relevant.
 
Top