Legacy GM SOLVED: Is it possible to use event collision in code for masks?

S

SVG

Guest
Should be a straight forward issue, but I can't find anything on it so I'm assuming there's no function for it.

Explanation:
So when you create a Collision Event with an object inside the event window of an object, it runs code only if it's own sprite's MASK collides/overlaps with the other object's sprite's MASK, even if it's an oval or diamond.

My question:
Instead of using the Collision Event, can I use a function in code to check for collisions between those 2 objects' masks?

Issue:
I've only found collisions functions that aren't checking the mask but rather the entire area around the sprite, or you can check 'precise'.

Need:
I want to simply check inside the Step Event if (this object's mask) collides with (that object's mask) {do this};
or is this way of thinking not good? Maybe it's bad practice to force game maker to check mask collisions with each other outside of when it normally checks for them...
 

jo-thijs

Member
Should be a straight forward issue, but I can't find anything on it so I'm assuming there's no function for it.

Explanation:
So when you create a Collision Event with an object inside the event window of an object, it runs code only if it's own sprite's MASK collides/overlaps with the other object's sprite's MASK, even if it's an oval or diamond.

My question:
Instead of using the Collision Event, can I use a function in code to check for collisions between those 2 objects' masks?

Issue:
I've only found collisions functions that aren't checking the mask but rather the entire area around the sprite, or you can check 'precise'.

Need:
I want to simply check inside the Step Event if (this object's mask) collides with (that object's mask) {do this};
or is this way of thinking not good? Maybe it's bad practice to force game maker to check mask collisions with each other outside of when it normally checks for them...
Sounds like you're looking for place_meeting and instance_place.
It's definitely not bad practice to use those.
 
  • Like
Reactions: SVG

CMAllen

Member
place_meeting() (if you don't need the collision object's id for any reason) or instance_place() (if you do want/need the collision object's id) will check for collisions between two objects' masks. Now, the only caveat to this is that if EITHER mask is set as rectangular and automatic, it will only do the collision check using automatic rectangular collision masks for both objects. Something to keep in mind. You shouldn't mix and match precise and non-precise masks.
 
  • Like
Reactions: SVG
S

SVG

Guest
Sounds like you're looking for place_meeting and instance_place.
So this isn't much different from collision_point() except place_meeting does look at the masks from the calling instance and the object its checking. So check this out, I've been programming on and off for about 3 years, and have never used place_meeting() before lol, interesting eh? It was the type of game I was building though, never needed it before. This does solve my issue, thank you guys!
 
Top