• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

GMS 2 Collision with one object precise and one not-precise

Skull_k

Member
Hi,

I use IDE V2.1.0.212 and run time 2.1.0.136.
In GMS2 manual, we can find the following sentence with the picture for place_meeting :
"This will work for precise collisions, but only if both the instance and the object being checked for have precise collision masks selected otherwise only bounding box collisions are applied. "

I tried to reproduce the example but i didn't have the result expected :
-I created two sprites : a cricle with precise collision ( i chose "precise (slow)" in collision mask)
a rectangle with not precise collision (i chose "Rectangle (fast)" in collision mask).

-I create two objects : a circle with the circle sprite (collision mask is "Same As Sprite")
a rectangle with the rectangle sprite (collision mask is "Same As Sprite")

In circle object step event, i put this code (it is my only code in the game):
if place_meeting(x,y, O_Rectangle) {
show_message("Collision") ;
}
And i placed the circle and the rectangle like this in the room :
upload_2017-9-21_16-9-50.png

I expected to have a message "Collision" but game maker does not detect the colision.
When i put sprite circle with not-precise collision mask, it detects a collision...

So, does someone could explain why i have this behaviour ?
 

Attachments

Jakylgamer

Member
because when using precise the circle in your image is not colliding with the square its off by like 2 or 3 pixels.
precise will use the shape of the sprite along the edges.
when its not precise it will use a square for collision mask.

example img
 

Skull_k

Member
Hello,

Thank you for your reply, but my point is that it is in contradiction with the manual. In the manual, we can see the following picture :
upload_2017-9-22_8-33-35.png

So, if i understand well the manual, in my example, game maker should "switch the circle to not-precise collision" because the rectangle is not precise when we apply place_meeting. But this is not the case in my example.

So, is there a mistake in the manual or i don't understand well the manual ?
 

Jakylgamer

Member
i think the manual is saying if one has precise collision checking and the other doesnt it will still cause a collision between the 2 but it will not appear to be precise because one is not using precise collision checking.
 

CloseRange

Member
The only way to alter the mask in the code is to change the mask_index and even then you cant say 'precise' or 'not-precise' that only changes the sprite_mask to refrence.

place_meeting will always check if the masks are touching each other. If you set both masks to be not-precise then yes you would get a message saying "Collision"
 

Skull_k

Member
Thank you for your response.
I just tried to reproduce the example, and i didn't have the result that i expected.
Anyway, i understand that GM will check the collision mask seting up in sprite editor.
 
Top