Simple delay using DND?

Discussion in 'Programming' started by TorQueMoD, Jun 3, 2017.

  1. TorQueMoD

    TorQueMoD Guest

    So I was following the tutorial series for making a shooter game with Drag and Drop. For the shooting functionality the tutorial has us create a variable for cooldown, set it's value to 0 and then only allow shooting when that variable is less than or equal to 0.
    I wanted to add a delay before setting the cooldown value so that I can shoot for the duration of the delay (10 seconds) and then the cooldown variable is set, there's a period where I can't shoot and then shooting is enabled again.
    Here's the setup:

    My problem is that the Alarm Countdown doesn't seem to have any effect. I'm not sure if this is a proper delay function but it was the only one I could find that had anything to do with time.
  2. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Apr 21, 2016
    "Set alarm countdown" configures an Alarm event to trigger in the given number of frames, so that's indeed not really what you wanted.

    If your goal is to simulate weapon clip (short delays between multiple shots and a longer delay every now and then), you could make a second variable to mark the number of shells remaining in the clip, decrease it by 1 after each shot, and set weapon_cooldown either to regular value if there are still shells left, or to a higher value (while resetting the shell counter) if there aren't.
  3. TorQueMoD

    TorQueMoD Guest

    So there isn't a delay node anywhere? That seems a bit strange. I also couldn't find out how to do booleans with this engine either.
  4. Specter

    Specter Member

    Jun 20, 2017
    The alarm is being reset to 10 every frame in the step event so it never counts down, check to see if it =-1 first then set it to 10 if that is true. Also like I'm sure you've heard all over these forums that GML is the way to go, and it is. I used to be a Drag and Drop fanatic, and hated GML, now that I've been learning GML I hate Drag and Drop especially GMS2 version lol. If you would like to step up to GML but think it's to hard, check out this course You'll learn a lot and be glad you did. This course uses version 1.4 but GML is pretty much the same throughout all versions with some changes here and there, but everything in this course should work with all versions.
  5. Cartoonicus

    Cartoonicus Member

    Sep 11, 2019
    Adding to the question: Is there a way to set a variable only after a given animation or sound file has finished playing?
  6. spoonsinbunnies

    spoonsinbunnies Member

    Aug 24, 2018
    image_index is the variable name for what frame of the set sprite you are showing, so by checking if that is above the second to last frame(this is slightly better than checking if it is the last frame because floating point is sometimes a thing in gamemaker) you can make something happen the very last frame of an animation.

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