• 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!

Simple delay using DND?

T

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.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
"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.
 
T

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.
 

Specter

Member
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.
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
www.gameprogrammingcourse.com 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.
 
Adding to the question: Is there a way to set a variable only after a given animation or sound file has finished playing?
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.
 
Top