place_meeting not working?

Discussion in 'Programming' started by corwin22, Jun 16, 2018.

  1. corwin22

    corwin22 Member

    Joined:
    Nov 18, 2017
    Posts:
    73
    This is the code I am using and both objects have a mask
    if (place_meeting(x,y,obj_orb))
    {
    hp = hp - 1
    }
    but it doesn't work at all
    the strange thing is that the orb with almost the same command
    if (place_meeting(x,y,obj_Wall)) {
    instance_destroy()
    }
    and it works so i am pretty confused?
     
  2. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    1,955
    Could be that the orb's code runs first. It checks for collision and destroys itself. Then the wall checks - nope, no collision because the orb no longer exists.
     
    EvanSki likes this.
  3. Jdown79

    Jdown79 Member

    Joined:
    Aug 21, 2016
    Posts:
    69
    Also, not related to your issue directly, but change this to
    Code:
    hp -= 1;
    Or more preferably,
    Code:
    hp --;
    The second code will minus one just the same, and the first one is the better way to write it if you ever subtract more than one, for example
    Code:
    hp -= 5;
     

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