• 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 collisions per frame - possible when drawing by code?

F

Finn

Guest
I have some objects with hitboxes that require precise collisions per frame.
For several reasons I would like to be able to draw the sprite myself but this seems to disable precise collisions per frame; instead the collision mask used is the one from the first subimage of the sprite (first frame).

Is there a way to be able to draw the sprite in code instead of having GML do it but keep the precise collisions per frame?

Reasons why I want to do that:
a) control animation speed dynamically with code
b) control image rotation and image_scale with code

Thank you!
 

NightFrost

Member
When you decide to do a customized draw, it doesn't change the object's properties (which makes sense, as you can do as many sprite draws in an object as you please). As far as collision checking is concerned, the proper way to interact with an object is to check against sprite information that is set into its built-in variables. If you want for it to behave with your custom selection, you must set all the relevant variables.
 
F

Finn

Guest
Thank you, I am not sure which custom variables you mean. I am using image_blend, image_xscale, yscale, etc. when drawing the sprite but dont know how to tell GM which sub image to use for collision checks in instance_place() functions. The collision mask_index is automatically set to the sprite selected. However, it is supposed to change over time following the setting "precise per frame".

Concrete example:

I have a melee hitbox object that requires precise collisions depending on the current frame/subImage of the sprite beeing drawn following its animation.
Within that object I am using the function instance_place_list() which uses the collision mask of the object which calls it - in this case that is the collision mask of the sprite associated with the object. However, that sprite's collision mechanics are set as "precise collision per frame" is selected - so the mask is not static but changes according to the sprite's animation or current sub image.
  • My observation is that when letting GML handle sprite drawing it automatically changes the mask_index according to the sub image it is currently drawing.
    Letting GM draw the sprite can be done by just not using a draw event while having visible enabled.

  • However, when there is draw code, the collision mask_index is always set to a static mask in every check of instance_place and I dont know how to manually change the collision mask according to the current sub image beeing drawn.

Any ideas how to handle this?
 
Top