UE5 Understanding Delay - Be a better game dev

Поделиться
HTML-код
  • Опубликовано: 10 июл 2024
  • In this episode of be a better game dev, we will be looking into the Delay node.
    Be a better game dev playlist: • Be a better game dev
    Join the Discord server here: / discord
    Support the work of LeafBranchGames on Patreon here: / leafbranchgames

Комментарии • 93

  • @HumpaLumpaBiriBam
    @HumpaLumpaBiriBam 3 месяца назад +7

    tip: UE5.3, "Delay 0.0 sec" has its own function name called "Delay Until Next Tick"

  • @gokuvinod2850
    @gokuvinod2850 6 месяцев назад +15

    wow just deleted 4 delay nodes out of 5 from my char and replaced them with time handler, never knew this time handler node could do soo much things, thank u soo much keep more of it coming!!!

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад +1

      Glad to hear about your improvements!

  • @Mohit_N.R
    @Mohit_N.R 6 месяцев назад +3

    This series is Great !! There aren't many or no videos that explains things likes this.

  • @OnZFlyStudio
    @OnZFlyStudio 6 месяцев назад +5

    Being thus early feels criminal. Thanks for the info!

  • @real2late
    @real2late 6 месяцев назад +4

    Very useful. I knew that it probably wasnt a good idea to use this, I didnt know why though

  • @thegreendude2086
    @thegreendude2086 6 месяцев назад +2

    Loving the series, theres a lot of stuff you kinda just pick up as you learn, just hoping that itll work and it often turns out that you should understand what you are using. On that note, I never actually used a timer as a timer, but for the time driven loop. Its simple stuff like that, thats making the videos really enjoyable for me.

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад +1

      Thank you for the feedback, glad to hear you like it!

  • @strick9red
    @strick9red 6 месяцев назад +1

    This is such a nice channel and the info is invaluable, thanks for making these mate your a big help.

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад +1

      Thank you, appreciat the kind words!

  • @mahkhardy8588
    @mahkhardy8588 6 месяцев назад +2

    Great topics, great video series. Thank you.

  • @MKVarfalomey
    @MKVarfalomey 2 месяца назад +1

    Thanks!!

  • @user-gg5zl8kv1r
    @user-gg5zl8kv1r 6 месяцев назад +1

    Very helpful tutorial, looking forward to the next tutorial!

  • @lolaswift111
    @lolaswift111 6 месяцев назад +1

    Greatly appreciated your sharing

  • @Ares9323
    @Ares9323 6 месяцев назад +2

    I joined a project and I found several actors with delays on a sequence node in tick, I wanted to scream 😂

  • @mattyheya
    @mattyheya 6 месяцев назад

    Wow this is really useful knowledge that isn't obvious whatsoever

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад

      You are right. Pretty fantastic and useful knowledge.

  • @now_ever
    @now_ever 6 месяцев назад +1

    Thank you for sharing!

  • @mikoajtarkowski4083
    @mikoajtarkowski4083 3 месяца назад

    You're right, I added a delay 0,1 sec to my event tick and was happy to finally get working code for me. :D
    I wonder then how to approach the topic of directional fighting style. I had previously assumed that every 0.1 seconds I would do an actual check of which direction the player moved the mouse and based on that movement, indicate which attack animation to use. This results in the need to check frequently, but only when the player has his weapon drawn. I think I need a high frequency of checking this, but certainly not as often as the event tick itself provides.

  • @DmitryNazarovMmitekk
    @DmitryNazarovMmitekk 6 месяцев назад +1

    Thank you - it was useful!

  • @andrzejmnich1285
    @andrzejmnich1285 6 месяцев назад +5

    Personally I don't like Delay nodes and always tell my student's no to use them. Unfortunately there are moments when even I use them. One of those is when I use OnTextCommitted and try to SetFocus on the end. Don't know why but without Delay of 1 tick this won't worka. Will have to dive into the C++ code of this module to understand it.

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад

      Sounds like good advice to me. That specific scenario was new to me. I will try to keep that in mind for the future.

  • @viniciusnoyoutube
    @viniciusnoyoutube 6 месяцев назад +1

    Very good video.

  • @Eludium_SNKN
    @Eludium_SNKN 6 месяцев назад +3

    Great tutorial, as always!
    If we're talking about scenes that absolutely cannot be interrupted by user input (e.g. cutscenes, scripted events), would you still say that the Example #1 in this video is bad practice, or not? Of course the developer can always use a timer by event in order to stay on the safe side, but doesn't that timer reference eat up some RAM? Would a delay be preferred in such a situation, for performance reasons?

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад

      A delay would be fine in such a situation. Adding timers means creating a delegate and having a few more steps to setup. Then it is simply not worth it if you are just after a "wait for a second or two" kind of logic.

  • @thesanestsaint
    @thesanestsaint 6 месяцев назад +1

    Great video as usual 😯. Are you planning on making animation procedure next?

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад

      Thank you!
      Do you mean procedural animations or best practices for animations?

    • @thesanestsaint
      @thesanestsaint 6 месяцев назад

      @@LeafBranchGames I mean the first one. As your past projects are really easy to scale so i was wondering why you haven't talked about animation.

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад

      @@thesanestsaint Animation is not one of my strongest sides. I may visit the topic, but I am not sure.

  • @Gastrostomi
    @Gastrostomi 6 месяцев назад +1

    Very nice.

  • @lospe85
    @lospe85 6 месяцев назад

    Thank you for the video! I didn't know how to implement dispatchers to check when a function/macro finished executing and your explanation helped me a lot... but going back to the "Delay" thing: what would be, in your opinion, they best way to set up "automatic fire": with a Gate an a Delay , or calling a Function by timer?

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад

      Unsure. I would have to experiment a bit to see what gave the best result. For sure I would not start with delay but instead a timer.

  • @jacksonblack3809
    @jacksonblack3809 6 месяцев назад +1

    Not sure if this is covered in the video but Delay does not function in c++ as you would expect. Doesnt postpone the compiler at all.

    • @jacksonblack3809
      @jacksonblack3809 6 месяцев назад +1

      One other thing if I recall correctly is because timers (and delays) are asynchronously processed, and not necessarily on the same thread, this can create issues as well as the timers will fall out of sync.

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад

      It is different, that is true.

  • @MIKELENZTIPS
    @MIKELENZTIPS 6 месяцев назад +2

    Love this thorough explainer! Thank you and all my best

  • @taylorhead9842
    @taylorhead9842 2 месяца назад

    I had an issue where my player ship has a set of spikes in the front and when boosting to run through 10+ enemies it was inconsistent. Sometimes it would work perfect other times the player ship would take damage from the enemy's overlap logic. What was happening is the enemy's collision overlap would sometimes fire before the spikes logic detecting an overlapping actor. I put a small 0.01 delay on the enemy's overlap collision and it allowed the spikes overlap to run before detecting the enemy overlap every time. Other uses I've found are for slowing down how often logic will fire. My game has lots of score mechanics with multipliers that drop based on the player taking any damage and to avoid an extreme amount of multiplier drop I've used 0.2 to keep it from dropping fast. Retriggerable delays can be helpful for times where you want to keep resetting some logic. Maybe the player is using an item but if they keep spamming the button it wont start the recharge until they stop. I think the really bad examples though are the looping timers people make with them.

    • @LeafBranchGames
      @LeafBranchGames  2 месяца назад

      These examples you are mentioning would benefit from event based logic instead.

  • @plank2490
    @plank2490 6 месяцев назад +1

    Thanks for the upload!
    How would you recommend to approach things like health/mana regeneration?
    I currently have a system that regenerates mana by recalling the same function once every 0.033 seconds (using delay) if a certain flag is active.
    Is that a good use of delay?

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад

      The examples in the tutorial would make for better regeneration in general. Delays, again, are very inflexible. What if you want to delay regeneration beceause you don't want to regenerate health in combat? Or maybe some other effect halts the regen? Well, you just pause the regen timer for that duration or during those circumstances.

    • @plank2490
      @plank2490 6 месяцев назад

      @@LeafBranchGames That what the flag is for.
      My question is: how else how would I apply something that needs a smooth change of a value, like HP during health regeneration, without the delay node?

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад

      @@plank2490 A timer gives a smooth change, has better precision because it can be stopped in a smaller increment than the delay duration.

    • @plank2490
      @plank2490 6 месяцев назад

      @@LeafBranchGames Ok I wasn't sure about the difference in this case. Thanks!

  • @WrongRong-KiRong
    @WrongRong-KiRong 2 месяца назад

    Please continue the card system videos

    • @LeafBranchGames
      @LeafBranchGames  2 месяца назад

      The card system is complete. There is no series to continue. It would be to make additional systems or something then, which would be its own series.

  • @azaelue5
    @azaelue5 6 месяцев назад +1

    Very nice video, but does it influence performance in any way ?

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад

      Thank you! Timer is more costly than a delay in that it forces you to have a delegate created and possibly a timer handle and such. It is also a few more steps than a delay node. But I would call all of that negligable, if responsiveness is what you are looking for.

  • @Drakuba
    @Drakuba 6 месяцев назад +1

    man, i remember seeing many tutorials where they used delay rather freely i had no idea...
    tho i remember someone mentioning instead of delay in your third example its better to use Is Valid
    anyway good to know 👍

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад +2

      The issue with a is valid is that it will check once, and then if it is not valid, then you will not call the functionality - ever. Since the check only happens once and at one point in time. It will not actually handle a situation where it needs to load an unspecified amount of time.

  • @GiulianoVenturo
    @GiulianoVenturo 6 месяцев назад +1

    pretty specific but how do you manage delays without Set Timer nodes? For examples I was doing a UI using an xbox controller, I had a custom Button BP (yeah I had no idea you can do a custom button BP) but because the button BP doesn't have a event tick I had to use a Set Timer Node as a "fake tick event" that basically constantly checks if the button is being "focus". After doing all my main menu everything was fine and cool but when I get for the paused menu it didn't work, basically all the Set Timer Nodes also stop when you use the "Pause Game Node". So I had 2 options make another custom button but parent it from a widget cuz then I can use it's event tick (yeah widgets ticks still running just need to do a small set up) or making a BPInterfaces so then I make ref to all my buttons and called them into the event tick of the widget itself (I went for the second option because having a custom button BP it was cool). What about you? what approached would you made and why?
    Also thanks for all the videos, I always try to watch them everytime I can!

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад +1

      Thanks for the support!
      I assume the button you talk about was inheriting from object, not an actor, so that us why you did not have tick?
      If tick is paused, you could try calling the "Set tickable when paused" to have it keep running even in paused mode.

    • @GiulianoVenturo
      @GiulianoVenturo 6 месяцев назад

      ​@@LeafBranchGames yeah I think the "Button BP" it's inheriting from an object. Yes my solution was making a function "update button" that then its call in the widget where all my custom buttons are. That's why I asked what other solution you would have? because I liked it when I have to write less code so my custom button only need to be call at the being play because it had a "Set Timer Node", but when you paused the game all Set Timers Node get also paused

  • @namesthatihate7185
    @namesthatihate7185 6 месяцев назад +1

    Should I also avoid retriggerable delays?

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад

      That is essentially the same thing, yes.

  • @allashama
    @allashama 2 месяца назад

    Hi i have a question! What about connecting a delay 0.0 or 0.1sec to an IsValid node? to see if a variable is valid before doing next. Someone told me that using IsValid with a loop on delay is not a good practice. Sometime, the engine run code faster than other, and because of that, the variable could end up detected NULL while the frame after is now recognised and Set.
    Thanks for the tip!

    • @LeafBranchGames
      @LeafBranchGames  2 месяца назад

      Delays are bad. You should never have logic depend on delays unless you know why you need it. Most people use delays because they don't know what is going on, so a delay might fix a problem early on but whatever took 0.1 might take 0.2 seconds later on. Then the code will fail.

    • @allashama
      @allashama 2 месяца назад

      @@LeafBranchGames ok i see, thank you! and what about a delay at the end of an execution? exemple, when my Character leave the Vehicle, i have to wait 0.2sec before enabling the collision between the vehicle and the Player because if i do it earlier, (without delay) then there is a collision and both start to glitch and lag.
      So i need a delay to wait for the player to be outside the vehicle to enabling the collision.
      For specific things like that, that really need a delay, should we still use a delay, or there is an other technicle?
      Thanks for your time!

  • @finesseandstyle
    @finesseandstyle 4 месяца назад

    I use a delay for projectiles to die once they've travelled outside of their max range (time calculated from velocity). I could have used a timer but a delay is more simple here

    • @LeafBranchGames
      @LeafBranchGames  4 месяца назад

      Or you could set lifespan and avoid delays.

    • @finesseandstyle
      @finesseandstyle 4 месяца назад

      @@LeafBranchGames Ah didn't know about that, ty

    • @finesseandstyle
      @finesseandstyle 4 месяца назад

      ​@@LeafBranchGames Also I use delay for animations in UI, to prevent the player from spamming the same animations

    • @LeafBranchGames
      @LeafBranchGames  4 месяца назад

      @@finesseandstyle And if your character gets hit during that animation so you want him to abort what he was about to do, you will not be able to stop whatever code is after that delay.

    • @finesseandstyle
      @finesseandstyle 4 месяца назад

      @@LeafBranchGames It's just a shake effect for an unavailable cooldown ability. If you press it while it's on cooldown you get a feedback, the delay works pretty well without issues

  • @wormjuice7772
    @wormjuice7772 5 месяцев назад

    For initalising something there is a good alternative using a delay.
    Is valid? False Delay (0.05) loop back into is valid node? True, then Continue onwards.
    This keeps the delay short and works like a timer without the need to bind things.
    But yes, use in rare situations.

    • @LeafBranchGames
      @LeafBranchGames  5 месяцев назад

      Would not recommend it. Try to use more event based programming.

  • @Alexlinnk
    @Alexlinnk 23 дня назад

    Some of the Don't cases were hard to watch 😬😬

  • @jimmyportfolio
    @jimmyportfolio Месяц назад

    Do you do consulting for projects?

  • @cristobalthompson2932
    @cristobalthompson2932 6 месяцев назад

    Im making a day and night cicle with an event tick, but I was adding a delay of 1 second so it doesn’t check the time every tick. Now I see is a bad practice. How would be the right way?

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад +1

      If you only need it to happen once per second you could change your tick interval. You can check this out for details: ruclips.net/video/-QvPxp138qQ/видео.html

    • @cristobalthompson2932
      @cristobalthompson2932 6 месяцев назад +1

      @@LeafBranchGames thanks for your answer, it seems a have a lot of optimización to make deleting delays and improving ticks. I’m using unreal insights but I don’t fully understand all the data. Waiting for task may be all the delay nodes. In a future video you May teach us to understand or how to read all that data. Thanks again for your content

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад +1

      @@cristobalthompson2932 I will put it on my to do list.

  • @IstyManame
    @IstyManame 6 месяцев назад

    Binding is pretty useful info, but about event tick part - you can't just say "don't use delays" like i added them for fucking fun and removing them won't do anything. In other parts of the vid you proposed alternatives so what's stopping you from doing the same for this part

    • @LeafBranchGames
      @LeafBranchGames  6 месяцев назад

      In both videos I explained that using tick and delays is mixing two different concepts. It is like saying I need to hammer this nail, let me get an ice cream machine. They do not have synergy and work against eachother.

  • @_Garm_
    @_Garm_ 6 месяцев назад +2

    tackar :)

  • @3zzzTyle
    @3zzzTyle 5 месяцев назад

    So basically delay (aside from 0.0) is only good for something uncancellable? Makes sense why it's a poor fit for most game logic, when that game is always taking unpredictable player input.