Using a Timer for Shoot Delay | QA - Godot Engine

  Рет қаралды 35,120

Ivan Skodje

Ivan Skodje

Күн бұрын

Demonstrating how you can create and use a Timer to make a forced delay between shooting a cannon ball.
Extra Timer Notes:
You can also add the Timer Node directly on your scene. If you do, you would use timer = get_node("path/to/timer_node") instead of using Timer.new() and add_child(timer). You can set the properties directly on the node.
Project Files ↣ drive.google.c...
QA-Link ↣ godotengine.or...
Contact Information:
Web-Site ↣ ivanskodje.com
Twitter ↣ / ivanskodje
GitHub ↣ github.com/iva...
Background music provided by Teknoaxe:
↣ • Royalty Free Backgroun...

Пікірлер: 77
@denizdemir9255
@denizdemir9255 4 жыл бұрын
Just what I needed. 4 years later, the tutorial still works!
@michaelazubuike2476
@michaelazubuike2476 4 жыл бұрын
Hey, that's why I'm here too😂
@SystemUpdate310
@SystemUpdate310 3 жыл бұрын
This is what I appreciate in Godot. These tutorials are just as useful as many years ago. The same can not be said about Unity at all. You can't follow a tutorial that was made with an earlier version, because nothing works the same.
@TheRealKaiProton
@TheRealKaiProton 3 жыл бұрын
5 yrs now
@iRaqi1
@iRaqi1 Жыл бұрын
6 yrs
@pixelwrinkly1528
@pixelwrinkly1528 3 жыл бұрын
the tutorial that keeps on giving still gold 4.5 years later many thanks
@zacktheslayer6564
@zacktheslayer6564 4 жыл бұрын
i appreciate the fact that you literally made a video just for this guy. youre awesome lol
@egosumcamax
@egosumcamax 5 жыл бұрын
Thank You so much from Brazil, unfortunality hir ,we dont have many content about godot.
@caimin6425
@caimin6425 2 жыл бұрын
nearly 6 years later still works like a charm
@IvanSkodje
@IvanSkodje 2 жыл бұрын
Thanks for sharing! You never know when these become outdated... !
@ClintGameDev
@ClintGameDev 6 ай бұрын
Thank you so much for this tutorial, i have searched for a long time for videos to understand godot timer but understood none.. but this video really helped me a lot to understand both custom and built in timers.. thanks
@Larington
@Larington 7 жыл бұрын
I struggled with this in all honesty, but I think that's purely due to working on something at 2 AM. This was really helpful, thank you.
@archimax08
@archimax08 Жыл бұрын
Exactly what I was looking for, worked for 3D too. Thanks!
@Warionator
@Warionator 4 жыл бұрын
I'm a bit late, but if you are more comfortable using nodes vs code, try this instead (same result) 1.) make a timer node a child to your object that's shooting the thing (this case the canon) 2.) enable One Shot on the timer and set your time to whatever you want 3.) Create a signal for timeout() and connect it to the parent (in this case, the canon) 4.) On your script, create a variable can_shoot = true 5.) On the newly created function, make can_shoot = true 6.) In your shoot part of the script, add an && can_shoot to your if statement 7.) at the end of the shoot section, make can_shoot = false 8.) now instead of timer.start(), we need to reference the timer node, so it would be something very similar, put $Timer.start() at the end of the shoot section 9.) If you named your timer, say shootTimer, you would put $shootTimer.start(). And that's it. The same thing just using more nodes vs script!
@Karce963
@Karce963 Жыл бұрын
Thanks for the extra tips, I'm a node-minded person too. In-case anyone was looking for a simple timer for the quit function (so a button sound can play).... Set a signal for the quit button and the timer that links them to the script of your choice. Same as above, but only 4 lines of code to quit with a button click (0.8 seconds is enough): func _on_quit_button_pressed(): $Timer.start() (*click and drag the timer from the node tree into the code to get the exact path) func _on_timer_timeout(): get_tree().quit()
@tunefulsoulonaroll7669
@tunefulsoulonaroll7669 6 жыл бұрын
Exactly what I was looking for, thanks for the tip.
@thebigbadbullyt
@thebigbadbullyt 4 жыл бұрын
Same.
@RyanScottForReal
@RyanScottForReal 4 жыл бұрын
Please do more tutorials! This really helps build the community and get new users to stick with it. Would be so great to link to these from the documentation in fact.
@L3ijona
@L3ijona 4 жыл бұрын
Thanks with this tutorial I figure out why my timer caused bug in my game. Also damn, your documentation is top notch, I just started cleaning my "close enought" documentation because your code.
@aZaamBie135
@aZaamBie135 3 жыл бұрын
Thanks so much man! It seems so simple yet I was struggling for hours xd
@Scarifia
@Scarifia 3 жыл бұрын
Great video, very useful, many thanks :)
@henrique.campos
@henrique.campos 7 жыл бұрын
Awesome as always! I'm really liking the Q&A series, thanks for that :D
@malithirm8711
@malithirm8711 Жыл бұрын
Helped me a lot, even in Godot4
@IvanSkodje
@IvanSkodje Жыл бұрын
Praise Godot
@haddo8054
@haddo8054 3 жыл бұрын
me: looking at this channel for the first time him: speaking me: lmao is this spongebob
@liegia
@liegia 4 жыл бұрын
Thank you! Hope to see more from you!
@herrkules8710
@herrkules8710 3 жыл бұрын
Thank you. I really needed this.
@c4r4dd1ct6
@c4r4dd1ct6 2 ай бұрын
If the connect method doesn't work for you, try replacing it with this line: timer.connect("timeout", Callable(self, "on_timeout_complete")) The connect method seems to have been changed to require a Callable for the second parameter, which would make the original timer.connect() line not work. Fortunately we have ChatGPT to help us now. It could also be the context I used this tutorial in (creating an Invoke method similar to the one used in Unity allowing for the user to hold down the jump button to jump repeatedly and consistently).
@JosephRDev
@JosephRDev Ай бұрын
Epic gamer Ty
@gonzalo3k
@gonzalo3k Күн бұрын
Thank you, this solved my problem!
@Pspisripoff
@Pspisripoff 7 жыл бұрын
This video rly made things a lot clearer! Thank you! P.S. perhaps in future videos you could made 2 attachments, one with finished code and one with a code that you got ready for the video (and yet didnt add the tutorial code) so people could maybe follow the video as it goes.. Thats just a though, even without it, great help! :)
@IvanSkodje
@IvanSkodje 7 жыл бұрын
Oh! Great idea!
@datalles
@datalles 2 жыл бұрын
thanks it helped me
@Khaner8
@Khaner8 4 жыл бұрын
I appreciate the tutorial but your voice is grating my soul.
@fossegutten6579
@fossegutten6579 7 жыл бұрын
Good tutorials and good voice :)
@IvanSkodje
@IvanSkodje 7 жыл бұрын
Thanks :3
@Danjovisagat
@Danjovisagat 7 жыл бұрын
Thanks man it helped a bunch!
@vinirodrisant
@vinirodrisant 3 жыл бұрын
Thank you my broda*
@nicolettiedu2522
@nicolettiedu2522 4 жыл бұрын
Incredible video, thanks!
@markyap3865
@markyap3865 7 жыл бұрын
Great job! Thanks!
@fedorrussel3810
@fedorrussel3810 4 жыл бұрын
Your channel deserves more love
@pogchamp1081
@pogchamp1081 2 жыл бұрын
thank you very much for this tutorial! it was very usefull
@emailcheat
@emailcheat 4 жыл бұрын
Thanks, it really really helped me
@That_One_Gamer211
@That_One_Gamer211 Жыл бұрын
very cool
@daisychan110
@daisychan110 5 жыл бұрын
It woked great. Thank you
@justdipp9625
@justdipp9625 4 жыл бұрын
thx you brooo!
@Antares2
@Antares2 4 жыл бұрын
I did this in a different way, though I don't know which method is "best": --------------------------------- var gun_cooldown = 2.0 ## Seconds between each shot var can_shoot = -1.0 ## any negative float will do func _process(delta): if can_shoot > 0: can_shoot = can_shoot - delta ## cool down weapon by fraction since last loop (delta) if Input.is_action_pressed("fireweapon") and can_shoot < 0: can_shoot = gun_cooldown [spawn bullets or do attack or whatever...] ---------------------------------- Works great for me at least.
@iRaqi1
@iRaqi1 Жыл бұрын
Nice idea 👍 I have q i went when press key can shot after 2 sconds Have any idea?
@arnaldoalange3869
@arnaldoalange3869 Жыл бұрын
It Worked Great for me, Thank You
@MartyJames23
@MartyJames23 2 жыл бұрын
Thanks, I did one with a TImer node for my 3d character's punch and the game froze. After work, I will try this version for my character.
@SamFX
@SamFX 7 жыл бұрын
Would it be possible to use some command like 'wait' or 'delay'? In other engines you have commands like this to create a delay for the next operation, I heard something about 'yield' on Godot but still seems overkill for such a simple feature. Any suggestions?
@IvanSkodje
@IvanSkodje 7 жыл бұрын
I am sure it would be possible. You dont even need to use a timer to create a delay. You can also create a time_current and time_max, and increase time_current using delta while checking if time_current has passed time_max before being able to shoot.
@SamFX
@SamFX 7 жыл бұрын
Hi, thanks for the tip. I will try that but I was expecting to have just a command to do this, in many other engines it's a mater of using 'delay' or 'wait' as a command and that's it. It seems like in Godot you need to create your own timer somehow which adds more steps than what it should be necessary in other engines. It's not as streamlined as others and I was hoping for a single command solution instead of a 'do-it-yourself'.
@ActionGamerAaron
@ActionGamerAaron 7 жыл бұрын
Often these commands will pause everything in the main loop and code in general, which is not advised for individual objects. You can make code that is passed over with a conditional that subtracts from the timer. # pass through here once to activate a timer for 90 frames or 1 & half seconds in a 60fps game action_timer = 90 enable_action = true [elsewhere in code...] if enable_action == true: if action_timer > 0: action_timer = action_timer - 1 # Subtract 1 for each frame that passes through this code else: # timer has reached it's end do_that_action_we_wanted_to_do() enable_action = false
@tatamimusicnetwork5253
@tatamimusicnetwork5253 7 жыл бұрын
Cool! Thanks
@samuelevander9823
@samuelevander9823 11 ай бұрын
Can someone explain to me this whole timer = Timer.new() -business? I have trouble understanding that syntax. What is it & what does it do? What part of Python fundamentals does it cover?
@IvanSkodje
@IvanSkodje 11 ай бұрын
GDScript is Python. Essentially Object.new() in GDScript means you are creating and initiating a new object. The new() function also runs the object's "_init()" function. So if you create a custom object, you could use the same MyObject.new() to initiate it.
@brianayate6312
@brianayate6312 8 ай бұрын
Question if you want to have yo make another timer is there a way to make a timer with out making it again like for shooting and throwing grenade
@stevesteak3209
@stevesteak3209 4 жыл бұрын
i got the error in the cannon ball script that get_pops isnt declared in the current class
@IvanSkodje
@IvanSkodje 4 жыл бұрын
Thank you for letting me know! get_pops? If you mean get_pos(), I believe it changed to "position" in Godot 3.0. So instead of "var.get_pos()" you would use "var.position". I also believe "var.get_position()" work. Try it out and see :)
@AlexVoxel
@AlexVoxel 6 жыл бұрын
Nice voice xD
@ActionGamerAaron
@ActionGamerAaron 7 жыл бұрын
Hm, not sure it beats out a classic "if cooldown, decrement cooldown, else allow shoot" loop. Adding a node for it has little advantage if you're able to count frames and in fact seems to convolute it slightly more.
@IvanSkodje
@IvanSkodje 7 жыл бұрын
Agreed - although this was a suggested solution for a specific question. :) (Especially if you already have a process going. If you don't, you might be better off using a timer for simple tasks such as this)
@bob64
@bob64 7 жыл бұрын
hi, i have been going back and forth between a hundred different tutorials trying to find out how to do what i think should be a very simple operation. i want to create a short screen before my menu (where you'd expect the name of a game studio, etc), fade to black, and then fade into the menu. any help at all would be appreciated as i am an amateur programmer at best.
@IvanSkodje
@IvanSkodje 7 жыл бұрын
Perhaps something like this? kzbin.info/www/bejne/b6SrfJSHd8iahZo
@bob64
@bob64 7 жыл бұрын
lol i'm embarrassed to say that the issue was that i hadn't connected my timer node to anything.
@fabiantjandra8763
@fabiantjandra8763 6 жыл бұрын
hi ! great video, is there any newest method to use timer? or still use this method?
@VaSoapman
@VaSoapman 6 жыл бұрын
Watch at 0.25 speed
@Dragokey
@Dragokey 5 жыл бұрын
It is creepier
@alasdairbarton
@alasdairbarton 6 жыл бұрын
I love your voice
@MrAstarcius-Chan
@MrAstarcius-Chan 2 жыл бұрын
2022 godot cant scan the project
@JulienBertozzi
@JulienBertozzi 6 жыл бұрын
omg, that voice. Are you Mordin Solus ?
@ZiRR0
@ZiRR0 2 жыл бұрын
i think i did it wrong rip
@kalabresa4329
@kalabresa4329 6 жыл бұрын
kkk thank´s
@matthewhall319
@matthewhall319 5 жыл бұрын
Come on man fix the voice
@fenokineza6259
@fenokineza6259 3 жыл бұрын
wtf
Using One scene instead of Ten, in Godot Engine
6:40
Ivan Skodje
Рет қаралды 21 М.
I Made My First Game in Godot in 3 Weeks...
26:21
Jack Sather
Рет қаралды 356 М.
He bought this so I can drive too🥹😭 #tiktok #elsarca
00:22
Elsa Arca
Рет қаралды 58 МЛН
Apple peeling hack @scottsreality
00:37
_vector_
Рет қаралды 126 МЛН
Je peux le faire
00:13
Daniil le Russe
Рет қаралды 21 МЛН
We made Vampire Survivors BUT in 10 Lines of Code
7:08
PlayWithFurcifer
Рет қаралды 1 МЛН
Godot Engine - Know Your Nodes: RayCast2D
14:12
KidsCanCode
Рет қаралды 42 М.
No, Einstein Didn’t Solve the Biggest Problem in Physics
8:04
Sabine Hossenfelder
Рет қаралды 205 М.
I Made Minecraft in Godot
28:36
RachelfTech
Рет қаралды 42 М.
Top Down 2D Shooting in Godot
18:33
Code with Tom
Рет қаралды 84 М.
⏰ Timers in #godot
18:25
Kyme Game Studios
Рет қаралды 1,5 М.
Godot Recipes: Animation States
10:31
KidsCanCode
Рет қаралды 106 М.
6 Tips to Better Organize your Godot Projects
11:39
GDQuest
Рет қаралды 135 М.
How You Can Easily Make Your Code Simpler in Godot 4
6:59
Bitlytic
Рет қаралды 425 М.
Making Successful Indie Games Is Simple (But Not Easy)
12:08
Jonas Tyroller
Рет қаралды 62 М.