Never use DELAY node in Unreal Engine | Use Timers Instead | Tutorial

Поділитися
Вставка
  • Опубліковано 23 лис 2024

КОМЕНТАРІ • 105

  • @madpuppet666
    @madpuppet666 Місяць тому +18

    You say its bad because "everything else after this node will wait for the time", but if thats exactly what you want, then delay is the cleanest way to do that. Running timers open the chance you forget to stop them so that is an error-prone and more complex solution than delay.

    • @chankulovski
      @chankulovski  Місяць тому +2

      Have you watched the video till the end, or just 10 seconds of it? That is causing the execution of the code to perform badly. Delay nodes are NOT synced with the user's computer Framerate, so it's not giving the same experience to every Player, because every computer has different Framerate. Timers are more complex solution and more optimized, that's why nobody bothers to optimize their code, due to lazyness. Also, even though I didn't mention something in the video, you should continue your research further. Let me help you with that, please check the link below.
      www.doppelganger1989.com/blog
      Scroll all the way down to read more.

    • @GMTechArt
      @GMTechArt 29 днів тому

      To avoid waiting, use Sequence.

    • @chankulovski
      @chankulovski  29 днів тому +1

      @@GMTechArt You can, but it's bad for your game. Doesn't mean if we can do things, that they are right things to be done.

  • @PalThing
    @PalThing 18 днів тому +3

    There's nothing wrong with delays, they are simply callbacks to execute async code. Timers do not accept parameters, which is a big problem with UE imho. Timers can introduce race conditions and create really hard to find bugs. Delays are great for things in 50-250ms region to delay gui updates.

  • @darkbionicle6
    @darkbionicle6 Місяць тому +5

    Hello there nice tutorial
    Delays are really good in certain situations and bad in others, they can be especially problematic with code flow execution where its easy to mess up the order of operation (but thats a general problem with delayed code) so i would generally say to be careful with using them in general!
    With that said, the solution you provided its not a bad solution, but if your main concern with delays is that they stop all code that comes after them, you could simply use a sequence (you can spawn one by holding down S and click with left click anywhere in the blueprint event graph) and use that to split delayed action with normal code execution.
    Hope this helps!

    • @chankulovski
      @chankulovski  Місяць тому

      @@darkbionicle6 Nope... Delay nodes are bad in every situation. They are made to quickly prototype some mechanics, but then they should be replaced with Timers. And the last but not least, only lazy people are using nodes like Delay, Casting, Event Tick, and they are finding all possible excuse to keep using it.

    • @darkbionicle6
      @darkbionicle6 Місяць тому +4

      @@chankulovski Im not sure where you have gotten the idea that delay nodes are always bad and that lazy people use them, but i can assure you that they are vastly used within the industry at a professional level as well. Sometimes taking shortcuts for certain scenarios is a benefit that one cannot just skip over.
      Moreover in the video as well as in your comment you haven't explained exactly why delays are always worse than timers apart from the specific case you have provided, do you have more to share on that?

    • @chankulovski
      @chankulovski  Місяць тому

      @@darkbionicle6 I will send you a link soon. Not everything can be said in one video. I can say more, but then the video will be too long and it will lose the effect of learning (rarely someone watches long videos, unless really really necessary, like creating a whole game/prototype or similar).

    • @darkbionicle6
      @darkbionicle6 Місяць тому

      @@chankulovski Awesome, thank you! :)

    • @chankulovski
      @chankulovski  Місяць тому

      @@darkbionicle6 www.doppelganger1989.com/blog
      Scroll all the way down :)

  • @Nitrohedge21
    @Nitrohedge21 Місяць тому

    Just got this video on my feed and I gotta say, using timers is really the way to go especially if you want the thing you're implementing to be frame rate independent. :)

    • @chankulovski
      @chankulovski  Місяць тому

      @@Nitrohedge21 I'm glad you're understanding and accepting the reality :) It's sad how many developers are denying these facts, just because they don't want to work a few minutes extra to optimize their code :) Thanks again for your comment, Keep an eye on the Channel, more great Tutorials are coming ✌️

    • @nmiles2go
      @nmiles2go Місяць тому

      Can you explain this point?

    • @chankulovski
      @chankulovski  Місяць тому +2

      @@nmiles2go What he's trying to say is, Delay nodes are not synced with the Framerate of every computer. Your computer will behave differently than mine in game, because you have a computer that runs on 120FPS, I have a computer that runs on 60FPS.

    • @nmiles2go
      @nmiles2go Місяць тому

      @@chankulovski Thanks!

  • @benblaumentalism6245
    @benblaumentalism6245 Місяць тому

    Timers are more accurate because they are not coupled to tick rate. They’re not truly async, but are not subject to variations of tick rate.

    • @chankulovski
      @chankulovski  Місяць тому

      @@benblaumentalism6245 That's correct. For example, having a Multiplayer game with Delay nodes will be unfair for someone due to their machine' different frame rate, because the Delays are not synced with the Delta time. Thanks for sharing ✌️

  • @ryanoconnor7957
    @ryanoconnor7957 Місяць тому

    you can easily remedy the problem you show by using a simple parallel node before the delay and continue to run logic while the delay is happening. people don't have to stop using delay

    • @chankulovski
      @chankulovski  Місяць тому

      @@ryanoconnor7957 I've explained 1000 times why Delay nodes are bad, I've made a whole Tutorial about it, and people STILL don't listen... I'm done explaining :) anyone can use anything they want in their game. Their game will be laggy, not mine.

  • @zeroonezeroonezeroone
    @zeroonezeroonezeroone Місяць тому +12

    How many full games have you shipped? It seems some devs are more interested in the act of making the game, instead of ever actually making anything.

    • @chankulovski
      @chankulovski  Місяць тому +5

      @@zeroonezeroonezeroone 11 games (some of them are on my itch.io). What I'm teaching here, I'm implementing the same things in my games. I hope these Tutorials are valuable to you. Thanks

    • @As_Ss
      @As_Ss Місяць тому +4

      @@chankulovski And how many of the games are more complex commercial releases u made on your own?
      I mean proper games?
      Show us the games.
      Anyone can make a simple game on itch and it will work fine, even if not build great, thats not a proof at all.
      Besides releasing any game is not a proof u are right.

    • @chankulovski
      @chankulovski  Місяць тому +6

      @@As_Ss Buddy, obviously you don't understand how these things work, and you are just trying to stay relevant and only want to comment and such. If you don't like what I'm teaching, kindly stop cluttering my Channel with nonsense and learn from other Tutorials. Have a great day

    • @StevenDiLeo
      @StevenDiLeo 8 днів тому

      Your question is irrelevant.

    • @chankulovski
      @chankulovski  8 днів тому

      @@StevenDiLeo Who's ? :)

  • @NebosvodGonzalez
    @NebosvodGonzalez 27 днів тому

    For some really simple code delay is still just fine but yes this is very useful for really big code tho.

    • @chankulovski
      @chankulovski  27 днів тому

      Well, for a small mini game, or something not that serious it's fine, yes. But this will become into a bad habit very quickly, so later when you want to create a bigger and better game, then you will have to learn Timers, so it's just not worth doing things twice. Better to learn at the beginning, so you don't have to bother about Delays.

  • @jhonyfernandez2703
    @jhonyfernandez2703 Місяць тому

    I have a question for you that you are the expert in this area... :), now I have a bunch of "Custom Events" and "Set timer events" instead of "Delay" nodes, there is a way to make this method reusable as a function or something like that to avoid that bunch of custom events?, Thank you!!!!

    • @chankulovski
      @chankulovski  Місяць тому +1

      You can use "Set Timer By Function Name". You have to create a Function and use it instead of Custom Events. This way, your code will be much cleaner and readable. But if you prefer to use Custom Events and Timers, you can create the Timers with Custom Events on the side, and then simply call the Custom Events' name to run the timer.

  • @crazyguy7585
    @crazyguy7585 Місяць тому +2

    actual delay is not bad ur talking about flow. use switch flow will also solve issue .if u r good in unreal engine u know where to put delay not between. like u show in bad example. ur good example is good for beginners 👍

    • @chankulovski
      @chankulovski  Місяць тому +1

      Delay node is not synced with the Delta Seconds Framerate of the players, and this will cause inconsistencies and unfair gameplay in Multiplayer. But I'm really tired of trying to explain something and people don't want to accept. If you believe Delays are great, use them a lot :)

    • @crazyguy7585
      @crazyguy7585 Місяць тому +1

      @@chankulovski for multiplayer yep its not good but i saw ur way u can use switch to pass flow no need to make another timer with custom event and one clear timer variable. instead using this use switch to pass node flow. there is node called switch u can put delay in 2 flow in 1 flow it will pass. i think u take me in wrong way i just say their is other ways too.

    • @madpuppet666
      @madpuppet666 Місяць тому

      @@chankulovski if delay doesn't use the manually modified player time delta, then that sounds like a bug in delay they should fix.

    • @chankulovski
      @chankulovski  Місяць тому

      @@madpuppet666 They should not fix anything. Epic Games gave us tools to work and to experiment, they won't do the hard work for us, they won't give us the magic button everything to be ready for us.

    • @madpuppet666
      @madpuppet666 Місяць тому

      @@chankulovski if user can alter timedelta, then the time used in Delay should work with that. if it doesn't its a bug, or it should be an option on the delay node to work with real time, or modified time. Otherwise the Delay node is useless.

  • @DevGods
    @DevGods 28 днів тому +1

    Hey, just letting you know, under the hood all the delay node does is create a timer. 😅

    • @chankulovski
      @chankulovski  28 днів тому

      @@DevGods If so, then why does Timer exists? :)))

    • @DevGods
      @DevGods 28 днів тому +1

      @@chankulovski Timer predates the delay node. Imagine having to create a timer and bind a delegate to it finishing every time you wanted to do something on a delay. Hence the delay node was made which wraps that logic up all nice and compact in a graph.

    • @chankulovski
      @chankulovski  28 днів тому

      @@DevGods Nope. Delay node is made to quickly test and prototype an idea, and then should be replaced with Timer for Optimization. People adopted Delay as their Go To node because they are lazy, it's that simple. But I'm done proving this over and over again, everyone can believe what makes them feel good and they can do what they want with their code.

    • @DevGods
      @DevGods 28 днів тому +3

      @@chankulovski Yea. Pretty much at the end of the day they both have a purpose. Delay is done async while timer is on the game thread. If you don't want to have to prove bold statements don't make them for clicks and views fam. This is the engagement you wanted when you posted this click bait title.

    • @chankulovski
      @chankulovski  28 днів тому +1

      @@DevGods Find ONE of my videos where I'm saying "Please like and subscribe", or any word that says "Subscribe", and I will delete my Channel completely. All I care is to share Programming best practices and Optimization. Instead of being grateful for the hard work we are putting here, you are being jealous and toxic... have a great life.

  • @VeganApps
    @VeganApps Місяць тому +2

    Never say never! Delays are great.. but not to create infinite loops, of course! oO

    • @chankulovski
      @chankulovski  Місяць тому

      @@VeganApps No ... NEVER use Delays, use Timers instead (if you want your game to run properly), it's very simple :)

  • @andrzejmikolajczyk9561
    @andrzejmikolajczyk9561 Місяць тому

    Since I'm pretty new to this stuff, I'm trying to figure out how to loop it. Need it for my line trace interaction.

    • @chankulovski
      @chankulovski  Місяць тому +1

      Just check the "Looping" Boolean, and when you don't need the timer, just Clear And Invalidate as shown in the video.

  • @jhonyfernandez2703
    @jhonyfernandez2703 Місяць тому +1

    I was Using a Sequence node and setting a Delay to bypass to the next code line xD

    • @chankulovski
      @chankulovski  Місяць тому

      Yes you can, but that's not the point. This is what Delay nodes are doing to your PC: CPU overhead: Delay nodes introduce unnecessary calculations and updates, which can strain your CPU, especially in complex or resource-intensive projects.
      Frame rate drops: Excessive delay nodes can lead to stuttering or frame rate drops, negatively impacting the overall user experience.
      Open this Article and scroll all the way down to learn more:
      www.doppelganger1989.com/blog

  • @FreeD00M
    @FreeD00M Місяць тому

    You can also use a sequence node with the delay in one slot.

    • @chankulovski
      @chankulovski  Місяць тому

      Yes, you can make things work with Delay, but the code won't be optimized, especially with more complex games or Multiplayer games.

    • @FreeD00M
      @FreeD00M Місяць тому

      @@chankulovski If you use a sequence node, then put the delay in sequence 1 and the code in sequence 2, i am pretty sure you get the same result, meaning the second code is executed in the same tick as the delay node.

    • @chankulovski
      @chankulovski  Місяць тому

      @@FreeD00M I'm trying to tell you: Delay node is NOT OPTIMIZED NODE, and it's not performing the same as Custom Event with Timer. Watch the Tutorials, and if you still believe Delay node is better, it's your choice.

    • @FreeD00M
      @FreeD00M Місяць тому

      @@chankulovski I did watch it. I just suggested that a sequence node can be used for parrallization with the event timer or a delay node, thats all.

  • @masterlkm
    @masterlkm Місяць тому

    Interesting.. I think I get it. Here is a question though, I have voice over in my game (I'm more of just experimenting, learning, not making an actual game) and for example if I jump, player makes grunt/jump sound. This grunt can't happen whenever I press jump, would sound weird, so the way I solved it was making a bool "shouldPlayJumpound?" and set it to true by default, then when I want to play sound, I check if shouldPlayJumpSound? is true, if yes, play sound, then I set it to false, then delay 4s and set to true after delay is over meaning the jump sound can play once every 4s. Would it be still better to use timer here? I'm just learning timers so I want to understand them better.

    • @chankulovski
      @chankulovski  Місяць тому

      Here's the thing... You can use Delays, you can learn how things work after few seconds, test an idea, prototype etc, that's totally fine. The problem is, this will easily become a habit and it's going to be VERY HARD to change in the future (as you can see many of the people who comment don't want to accept that Delays are bad and they are keeep using it, and their game suffer :)) Overall, if you are doing a very small Project, using Delays should be fine, but if you intend to become better and smarter programmer in the future, you should learn Timers and use them all the time (I never use Delays in my games, not even for testing or anything, I don't wanna see that node). So it's up to you :)
      Meanwhile, take a look at this Tutorial, maybe it will be handy for your Jumping mechanics:
      ua-cam.com/video/xeJUwXJUvZo/v-deo.html&ab_channel=Chankulovski

    • @masterlkm
      @masterlkm Місяць тому

      @@chankulovski Hey man, thanks for the extensive reply, really appreciate it! I see, so delays are really that bad huh? I'll try to translate everything into timers instead as you suggest, I'll also try to get more viewpoints on this topic from forums and such. In the meantime, I got your udemy course, looks very promising, has a lot of functionalities that are very interesting to me.

    • @chankulovski
      @chankulovski  Місяць тому

      @@masterlkm You are welcome buddy, doing my best! Go to this page and scroll all the way down, I wrote an article with a breakdown points, which part of the performance is affected:
      www.doppelganger1989.com/blog
      In the meantime, extend your research as you said, always check multiple sources and opinions, and decide what do you believe and go for it. Thanks for buying the Course, feel free to message me any time if you need anything.

  • @IterAeternum_th1Game
    @IterAeternum_th1Game Місяць тому

    11:32 Why not connect the SpawnEmitterAtLocation output to ClearAndInvalidate directly?

    • @chankulovski
      @chankulovski  Місяць тому +1

      GREAT POINT! :) You can do that, that's even a better option. But if you have more Blueprints and more complex code, it will become "spaghetti" messy very quickly. Having the "Clear And Invalidate" ready in a Custom Event will give you more clear and tidy nodes, so you can call that Custom Event as many times as you want, while keeping the nodes tidy and the code optimized.

  • @nullhakunamatatabyte8042
    @nullhakunamatatabyte8042 Місяць тому

    thx for this advice u show always better way the do it

    • @chankulovski
      @chankulovski  Місяць тому

      @@nullhakunamatatabyte8042 Thanks ! Doing my best :) Thanks for your kind words

  • @faxtm260
    @faxtm260 Місяць тому

    I usually use set timer by function name for values that I need to check instead of using the tick event, it's that ok?

    • @chankulovski
      @chankulovski  Місяць тому +1

      @@faxtm260 Set Timer By Function Name is also great! That's the same method like in this video with the Custom Event, so instead of Custom Event and Timer, you are using Function, so yes, it ok. Just make sure to Clear And Invalidate the timer when you finish your task.

    • @chankulovski
      @chankulovski  Місяць тому

      @@faxtm260 you are doing well, DON'T USE EVENT TICK, EVER ! Check out this Tutorial to see more clearly why :)
      ua-cam.com/video/HeotnYTZf80/v-deo.htmlsi=KLdtADB6QZhuzHIr

    • @benikeler
      @benikeler Місяць тому

      I would advise not to use the actual 'set timer by function name' node, but rather still you the 'set timer by event' and off of the event socket plug in a 'create event' node. You can select any functions or events with the same signature and they will be available from that node even though functions are not technically an event. This way you can avoid potentially misspelling the function name as a string.
      For me it's just a way to do the same thing with less chance of running into a bug from human error 😅

    • @chankulovski
      @chankulovski  Місяць тому

      @@benikeler It's practically the same, only the Function can have a Return node for an Output, other than that, it's just a personal preference. But yours make sense too :) Thanks for sharing !

  • @zoelbastianbach1792
    @zoelbastianbach1792 Місяць тому

    The problem with delay is when you use it with time dilation dynamically, somehow it count the seconds differently with actual time multiplied with time dilation and very undpredicted (the moment time dilation was set you must wait until next tick to use it with new time dilation setting).
    I use it when making auto test and delay node was very unreliable there. Same as timer in function/event, I don't even try to know whether the invocation time was changed based on time dilation or not (because invocation usually not).
    The solution I use was single node that automatically add Timeline component and configure all the Timeline setting via parameter and when finish it auto remove the component (or just leave it there when I use it for auto test purpose).

    • @chankulovski
      @chankulovski  Місяць тому

      Exactly right! That's because Delay nodes are not synced with the user's machine Framerate, so the Delay node will cause inconsistency and it will behave differently and unfair most of the times, especially in Multiplayer games! Timelines are also great, yes. Thanks for clarifying and sharing your experience :)

  • @attentivenettle7643
    @attentivenettle7643 Місяць тому

    I still don't get why the delay node is more expensive. It seems simple. Can someone explain please?

    • @chankulovski
      @chankulovski  Місяць тому

      www.doppelganger1989.com/blog
      Scroll all the way down, it's all there :)

    • @attentivenettle7643
      @attentivenettle7643 Місяць тому

      @@chankulovski
      Ok i read it. Thank you so much for replying and for introducing me to even timer

    • @chankulovski
      @chankulovski  Місяць тому +1

      @@attentivenettle7643 You are welcome! I always reply, so feel free to ask anything you want to know, I will do my best to assist you. More Tutorials are coming, so keep an eye on the Channel. If interested, I have a full Course on Udemy at a 40% discount, 30 days full refund if not satisfied, you can give it a try if needed. Thanks again!

  • @contrafactstudio
    @contrafactstudio 24 дні тому +1

    Блин, извини ты угораешь что-ли? Прежде чем учить возможно нужно мать-часть поучить. Извини не удержался. Не вводи людей в заблуждение!

    • @chankulovski
      @chankulovski  24 дні тому

      If you don't like it, DON'T WATCH IT! It's that simple. There are people who want to learn proper programming, so, relax...

  • @swrcPATCH
    @swrcPATCH 6 днів тому

    Your example is absolutely terrible. It is only something beginners would do, so even if you are right, you will NOT convince anyone with this example.
    But what I'd rather like to know is, how about the Do-Once-Node ? Should that be avoided too? Or is it just fine to be used?

    • @chankulovski
      @chankulovski  6 днів тому

      @@swrcPATCH That's your opinion, there are others who wants to learn the proper way, and they will. However, Do Once is a great node, it's fine and safe to be used.

    • @swrcPATCH
      @swrcPATCH 6 днів тому

      @@chankulovski I am not saying you are wrong. I just said the example so people can understand why the delay-node is bad, is a terrible example and not proving your point. The "proper" way would have a more understandable example in my opinion. All your example does is showing "why to use timers instead" but not avoiding "delay", you know what I am trying to say? Your video could be "use timers" but this example doesn't show why to avoid delay, it just shows why to use timers, do you get what I am trying to explain?
      Oh and good to know that do once is fine. I have not checked its implementation so I just wondered if it has some issues too.

  • @AstrovoidInvasion
    @AstrovoidInvasion Місяць тому +1

    Hy Merhaba Unreal engine ekibine bunu söyledim ve videonuzu onlara atıım çok pişman olduklarını ve bu hatayı neden yaptıklarını anlamamışlar bu yüzden size teşşekür edip bundan sonraki versiyonlarında delayı unitiye devredip unreal engineden sileceklerini söyledi bizde bu durumdan müzdaribiz oyunu delay üzerine geliştirdik oyunda binlerce delay var 5 yıllık emeğimiz silindi teşekürler

    • @AstrovoidInvasion
      @AstrovoidInvasion Місяць тому

      Здравствуйте, я рассказал об этом команде движка Unreal и отправил им ваше видео, они очень пожалели и не поняли почему допустили эту ошибку, поэтому поблагодарили вас и сказали, что перенесут задержку на юнит и удалите его из движка Unreal в следующих версиях. Мы страдаем от этой ситуации. Мы разработали игру из-за задержек. В игре есть тысячи задержек. Мы работаем уже 5 лет. Спасибо.

    • @chankulovski
      @chankulovski  Місяць тому

      @@AstrovoidInvasion Very funny 🤭 Also, I'm confused why you are commenting in Turkish and Russian languages :) but anyway :)

    • @AstrovoidInvasion
      @AstrovoidInvasion Місяць тому

      @@chankulovski We thought we were Russian

  • @warsarebeautiful3504
    @warsarebeautiful3504 День тому

    Trash clickbait …delay is good do not misguide

    • @chankulovski
      @chankulovski  День тому

      You are just one of those toxic trolls that knows no better than this... use your Delays as much as you want :) make sure to have 100 of them :D