Is there a simple way to make a Delay Wait instruction in GDscript???

fasasoftwarefasasoftware Posts: 2Member
edited November 2020 in General Chat

Is there a way in godot to make a simple call for a DELAY or a simple WAit in GDscript????
In basic or in c++ you write: Delay(1000) delay for a second or Wait for 1 second(Livecode)...thery simple....
I don't want to make a subroutine to wait 1 seconds!!! does exist a single instruction???
Can somebody help me???
Best regards,

Tags :


  • MegalomaniakMegalomaniak Posts: 3,211Admin

    Could use a timer, or yield?

  • RAMupgradeRAMupgrade Posts: 28Member

    It depends what needs to wait and why. In truth, you probably just want the player to wait for a moment, rather than paralysing the entire game process.

    BASIC works very differently to object oriented programming and you'll need to change your thinking a bit. BASIC progresses line by line, one at a time but OOP has simultaneous processes interacting with each other.
    Your game needs to handle various independent processes and you need to specify how, depending on how you structure your project and how you programmed the game. A wait or delay command could not do that.

    Ideally, your primary loop will run constantly and won't just freeze whenever you want the player to sit around waiting for a few beats. That delay should be a function which uses a timer of some kind (either a native timer object with a signal, or by counting delta increments in code). DO make a "subroutine" and call it whenever you need it. That's the way forward. Then you have full control over exactly how your specific game appears to "wait" and what it does in the background at the same time. Much cleaner, fewer headaches later on.

    (e.g: How will the game know if a button/key is pressed, or if the app gets sent to background and needs to enter pause/sleep mode? You cannot check for events like these when the engine is frozen. And how does it effect any in-game clocks? Those will stop counting while your game is waiting. The display will not update while frozen. etc. etc.)

    Assuming you genuinely want your primary loop to stop everything and just hang, for some reason, you could use OS.delay_msec (1000) but this should only be done with great caution! It's not recommended practice but it IS what you asked for. Hope that helps!

  • fasasoftwarefasasoftware Posts: 2Member

    I thank you so much for the answer.....but it's so boring to make a subroutine...but if there's no other chances...i'll do...I'll try also.. OS.delay_msec (1000) ....Thank you Ramumpgrade.., Lestroso

  • RAMupgradeRAMupgrade Posts: 28Member

    You are most welcome! Good luck! :)

Sign In or Register to comment.