[SOLVED] can I draw an instance's collision mask

Mr Errorz

Member
I want to see the collision mask of a certain instance while running the game,
preferably overlaid on top of the instance's sprite..
is there a way to draw it on screen while the game is running?
 

ph101

Member
Yes you can:

Code:
draw_sprite_ext(mask_index,0,x,y,1,1,0,c_aqua,0.5);
obviously changing the parameters as need be, and ensuring you have actually set your object's mask_index.
 

Mr Errorz

Member
Yes you can:

Code:
draw_sprite_ext(mask_index,0,x,y,1,1,0,c_aqua,0.5);
obviously changing the parameters as need be, and ensuring you have actually set your object's mask_index.
actually not what I was looking for,
but it got me to what I needed, and that's drawing the bbox of the sprite.

went for something like-
draw_set_alpha(0.5);
draw_rectangle_colour(bbox_left,bbox_top,bbox_right,bbox_bottom,c_red,c_red,c_red,c_red,false);
 

ph101

Member
Ok glad that works, it's not technically the collision mask, but the boundaries of the sprite you are drawing, which may or may not be the same depending on if it's a precise or imprecise collision check you are doing, and then how have the collision checks set for the sprite in the GM sprite editor in question. Glad it helped anyway.
 

TheouAegis

Member
Actually @ph101 it's still the collision mask. The bounding box is the boundaries of the collision mask, not the sprite, technically. The boundaries of the sprite are x-sprite_xoffset, y-sprite_yoffset, x-sprite_xoffset+sprite_width, y-sprite_yoffset+sprite_height.
 

ph101

Member
@TheouAegis Aha good point! So if using imprecise collision detecting then bbox would define the boundries checked for collision, but they would be determined by the mask_index if set or mask of the the sprite if set...
 
Top