Legacy GM Collision Mask is set incorrectly

Reed

Member
Is there something I'm missing about how sprite_collision_mask works?

I'm trying the make a mask that encompasses several instances that move together. The top and bottom instances are called part_top and part_bottom. The mask applies to obj_player.

I had thought the code below would create a rectangular mask stretching from the top of part_top to the bottom of part_bottom, 20px wide horizontally centered on the sprite origin. The mask it actually creates is zero pixels wide and pushed to the extreme left edge of the sprite (the origin is in the center, I checked), and I honestly have no idea where the height of the mask comes from.

I've read elsewhere that sprite_collision_mask does not allow bbox edges to exceed the boundaries of the sprite. This is not the problem I'm having because the sprite in question is 300x300 pixels and the instances I'm attempting to bound exist entirely within it.

Code:
//Create Event for obj_player:
var spr=sprite_duplicate(sprite_index);
sprite_collision_mask(spr,false,2,-10,10,part_top.bbox_top-y,part_bottom.bbox_bottom-y,1,0);
sprite_index=spr;
Here is a screenshot w/ debug info. I've blocked out superfluous information.
part_top and part_bottom are bones in the skeleton. The sprite for obj_player (to which the mask should apply) is the large green square, which is only visible for testing purposes.


The last two values posted on the screen are what the top and bottom bbox offsets from the origin of the green square ought to be. But if you add those values to player y, the values you get don't equal the actual locations of the bbox edges. They do however equal the "goal" locations for those edges which are simply the bbox edges of part_top and part_bottom when accessed directly. As I said before, the actual values of the new bbox top and bottom don't appear to be related to anything. And I already tried clearing the compiler cache.

Thanks for any help you can offer.
 
Top