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

Discussion in 'Programming' started by Skull_k, Sep 21, 2017.

  1. Skull_k

    Skull_k Member

    Joined:
    Sep 21, 2017
    Posts:
    10
    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. "
    [​IMG]
    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 ?
     

    Attached Files:

  2. Jakylgamer

    Jakylgamer Member

    Joined:
    Jun 27, 2016
    Posts:
    510
    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
    [​IMG]
     
  3. Skull_k

    Skull_k Member

    Joined:
    Sep 21, 2017
    Posts:
    10
    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 ?
     
  4. Jakylgamer

    Jakylgamer Member

    Joined:
    Jun 27, 2016
    Posts:
    510
    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 likes this.
  5. CloseRange

    CloseRange Member

    Joined:
    Jul 2, 2016
    Posts:
    815
    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"
     
  6. Skull_k

    Skull_k Member

    Joined:
    Sep 21, 2017
    Posts:
    10
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice