Open SuperFreaksDev opened 1 year ago
The first function sounds fine, the second, not so much imo. The second use case can very much be handled using the existing functions right now afaik, since you could just change the mask index of the object doing the hit test and test, change it to the next for the hitbox, test again, until you are done; no extra instances needed.
It would be nice if you could just check regular collisions using instances' sprite_index rather than their mask_index - you can temporarily change everything's mask_index and then change it back, but this can get expensive. Something like instance_place_sprite() maybe?
It would be nice if you could just check regular collisions using instances' sprite_index rather than their mask_index - you can temporarily change everything's mask_index and then change it back, but this can get expensive. Something like instance_place_sprite() maybe?
You can do this now...if you aren't manually setting the mask index, collisions will use the sprite's mask.
It would be nice if you could just check regular collisions using instances' sprite_index rather than their mask_index - you can temporarily change everything's mask_index and then change it back, but this can get expensive. Something like instance_place_sprite() maybe?
You can do this now...if you aren't manually setting the mask index, collisions will use the sprite's mask.
I am manually setting the mask index, which is why I mentioned needing to temporarily set and reset it. Again, this gets expensive when you're doing it over enough objects.
It would be nice if you could just check regular collisions using instances' sprite_index rather than their mask_index - you can temporarily change everything's mask_index and then change it back, but this can get expensive. Something like instance_place_sprite() maybe?
You can do this now...if you aren't manually setting the mask index, collisions will use the sprite's mask.
I am manually setting the mask index, which is why I mentioned needing to temporarily set and reset it. Again, this gets expensive when you're doing it over enough objects.
I am just not understanding why doing mask_index = -1
to unset the mask so it defaults to using the sprite_index is costly? Even then, you are just changing a ref to an asset which is certainly a small part of the frame budget in comparison to the actual collision test...
It would be nice if you could just check regular collisions using instances' sprite_index rather than their mask_index - you can temporarily change everything's mask_index and then change it back, but this can get expensive. Something like instance_place_sprite() maybe?
You can do this now...if you aren't manually setting the mask index, collisions will use the sprite's mask.
I am manually setting the mask index, which is why I mentioned needing to temporarily set and reset it. Again, this gets expensive when you're doing it over enough objects.
I am just not understanding why doing
mask_index = -1
to unset the mask so it defaults to using the sprite_index is costly? Even then, you are just changing a ref to an asset which is certainly a small part of the frame budget in comparison to the actual collision test...
I don't understand either! But in multiple projects there's been a measurable impact when I've performed this on enough instances - again, you aren't only doing this for the calling instance, but also for every instance of the object it's checking collisions against. But I don't know exactly why it's expensive; you'd have to ask someone at YYG.
In any case, it's also inelegant to have to set and reset the mask_index, since you also need to store the previous mask per instance. Many of the "other events" do collision checks using sprite_index
, such as Outside Room
and Intersect Boundary
, so it would be nice to have this functionality available for other applications as well.
Is your feature request related to a problem?
The collision checking methods we have now are pretty good, but if you want to collision check without masks, you lose access to using sprites and their masks for collisions. Sprite masks can be many different shapes including precise (which I know can be slow but sometimes you really need it) and it would be convenient to use them as hitboxes without having to create more instances for them.
Describe the solution you'd like
Some new methods to check if two sprites placed at different positions would be overlapping each other, similar to point_in_rectangle and etc.
Ex. sprite_in_rectangle(sprite_index, image_index, x, y, xscale, yscale, angle, precise, rec_x1, rec_y1, rec_x2, rec_y2) Ex. sprite_in_sprite(sprite1_index, sprite1_image_index, sprite1_x, sprite1_y, sprite1_xscale, sprite1_yscale, sprite1_angle, sprite1_precise, sprite2_index, sprite2_image_index, sprite2_x, sprite2_y, sprite2_xscale, sprite2_yscale, sprite2_angle, sprite2_precise)
With methods like these you could use sprite masks for collision checking at anytime no matter what, and with more control.
Describe alternatives you've considered
No response
Additional context
No response