[SOLVED] Destroy Effect error

Discussion in 'Programming' started by Guilherme Hernandez, Jun 5, 2017.

  1. Speak up, all right?

    One more question, I have a spawner that spawns several zombies. But when I squeeze to destroy a zombie, the Effect appears on another, and when I squeeze on another zombie the game crashes.

    The Effect, im doing with DnD... I dont know how do with Code.

    Like, I want the effect to appear only on the zombie I killed, not everyone on the screen.
     
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    7,072
    Please share a screenshot of the DnD used and also post the EXACT error you get. :)
     
    Binsk likes this.
  3. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,796
    This only ever happens to people who reference variables in object.variable form when multiple instances of the object are in the room.

    If the effect is created in the zombie's Destroy event, DO NOT create it at something like obj_zombie.x or obj_zombie.y. Leave the obj_zombie. part out of it and it will reference the current instance's coordinates. The same is true for any other instance property (e.g. sprite_index) or instance-scoped variable from within the same instance.

    Rookies need to stop trying to reference variables for the current or colliding instance using object IDs. If only mainstream GML education would do a more sensible job educating novices about scope and instance handling.
     
    Guilherme Hernandez likes this.
  4. The event that contains the effect is the LEFT RELEASED, because I thought it would be in the same place where the code destroying the instance.

    The problem is that I do not understand English very much, and practically all the tutorials are Portuguese, at least everyone I met now, so I'm having difficulties.

    Relax, man, I'm starting now with codes and with Game Maker. We all get something wrong or ask for help.
     
  5. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    7,072
    Okay, that's fine. :)

    I would still like to look at the DnD though... It may be that what @FrostyCat says is true but without actually seeing what you've done it's very difficult to help. It does sound like you are targeting an object rather than an instance though...
     
    Guilherme Hernandez likes this.
  6. I just succeeded in getting the effect to the place of the instance. I did as FrostyCat said, I just took the (objZombie.).
    I did not know it worked that way. Thanks for the help, and sorry for not knowing the basics walks. Like I said, I started a month ago.
     
    Nocturne likes this.
  7. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    7,072
    That's great! And don't let some people who are a bit direct about their advice put you off... They mean well. ;)
     
  8. I know, I was not mad or anything. Just think with a little more opinion because I started a little. But it's alright. : D Thanks to all who tried to help in a way!
     

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