GMS 2.3+ Question about collision mask rotation..

flyinian

Member
I've been following this YouTube tutorial for collision masking and so far so good. The video is time stamped when the collision code is complete for visual representation.

However, I'd like to make vehicles with collision but, noticed that the current collision system doesn't work with rotating collision masking that aren't even on all sides. It works great with squares but not rectangles.

What would I need to do to make the collision system work with rectangles?



The collision mask will remain in the horizontal position while the sprite rotates freely. Making the ends that aren't covered by the collision mask not be affected by Collision.

// The code from the video. Works well with square collision masking and square/smaller than collision mask sprites.
// Create
GML:
_Image_Angle = 0;
// Step
GML:
direction = point_direction(x,y,mouse_x,mouse_y);
_Image_Angle = direction;
// Draw
GML:
draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,image_yscale,_Image_Angle,c_white,image_alpha);

Thanks for the help.



post POST:
After posting this and a bit of brain storming. I may create a different collision system for rectangles. I haven't given it a long look but, this tutorial may do good.
Feel free to reply to the op.
 
Last edited:

Tyg

Member
Theres a point_in_rectangle function as well as point_in_circle or point_in_triangle
you can update the mask rotation right after you update the players rotation collider.image_angle = player.image_angle
or you can use matrixs..thats a long discussion though...lol
 

DaveInDev

Member
I am not sure , but if you are using draw_sprite_ext, you are bypassing the default sprite (usually drawn with draw_self) which is in relation with the default mask. To rotate the default mask, you should also update builtin variable image_angle (and not this_Image_Angle that you are using).
 

gnysek

Member
image_angle should rotate collision mask. Any draw_xxx function bypass drawing object, but doesn't touch collision mask at all. So, instead of using draw_ function, you may just need to use image_angle in Step event and skip Draw event at all.
 
Top