1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

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:
    2,090
    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