UE5 Understanding Tick - Be a better game dev

Sdílet
Vložit
  • čas přidán 18. 12. 2023
  • In this episode of be a better game dev, we will be looking into the Tick event.
    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

Komentáře • 72

  • @fordston2
    @fordston2 Před 6 měsíci +17

    Hope that more people can discover your channel, especially beginners. There are too many tutorial channels out there that propagate misconceptions. They attract viewers with seemingly quick solutions for specific functionalities (even claiming to teach you how to create xxx system. And in fact, the video only covers the creation of a widget from start to finish. Quite ridiculous), without considering if these methods truly meet the demands of game development-such as performance, logic, and scalable architecture. It's merely a waste of time for many because such approaches will never lead to the completion of a properly functioning game.

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci +6

      You are spot on in your observations. It is an issue that crops up problems for people wanting to learn far down the line of their Unreal Engine journey. At that point they have learned so many bad practices and have a skewed approach that changing those patterns will almost like starting from scratch.

  • @PixelsLaboratory
    @PixelsLaboratory Před 6 měsíci +6

    There are also BP nodes which allow you to control the Tick Interval for entire actors, or even individual components, which greatly allows for Tick behavior diversity!

  • @Louieeeee
    @Louieeeee Před 6 měsíci +4

    As an undergrad cs student working on their capstone which is a game in ue5, you are a literal life changer. Thank u so much for putting out such high quality information about industry standard practices in UE5.

  • @l_t_m_f
    @l_t_m_f Před 6 měsíci +10

    While the general advice is correct, and great video as usual, the example you give can easily run a tick with no problem. But I had a student recently follow a tutorial online and he put like a For loop in a For loop inside a function which was on his tick. Needless to say, when we would "stop" the game, it would freeze your PC for 5 minutes trying to finish dealing through the queued actions from that node. That single node was triggered 900 000 times a tick (there were like 20 instances running this craziness). That's an example of avoiding tick, but I find that the example you give actually doesn't matter much if it runs on a tick or not. You can also reduce the speed of an actor's tick in the details pannel if you know there's lot's of instances of it in your world. There reason is that Timeline is inflexible, it cannot change much, so its very different from moving the actor each frame.

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci +4

      I give three examples, so not sure which example you are referring to.
      Yes, there are of course more extreme examples of . They exponential cost of using a for loop nested in a foor loop is bad enough by itself, let alone in tick. Simply by having a thousand objects in an array looping over it in a nested loop equates a million times the inner loop executes whatever code it was aiming to execute. Less than ideal.
      So, yeah, there are worse examples. But even not very costly operations that can be handled in a different place than tick, is still a worthwhile goal to strive for. Both to avoid using Tick as a crutch and also to keep it from running code that really doesn't need it.
      The speed of tick was discussed in the end of the video.

    • @l_t_m_f
      @l_t_m_f Před 6 měsíci +1

      @@LeafBranchGames Thanks i missed the last 2-3 minutes of the video actually xD

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci +1

      @@l_t_m_f No worries.
      Like I said in the video, I did oversimplify some things a bit, because there are some details that makes things fuzzy and more gray than black or white. But I tried to get it as right as I could without spending too long on the subject. Still ended up 20 minuts long though.

    • @l_t_m_f
      @l_t_m_f Před 6 měsíci +2

      ​@@LeafBranchGames the video was great man! just pointing out for most programmers the danger comes from pure nodes hiding heavy stuff like loops being used unknowingsly on the tick not such much about fine tuning optimization like you did in the video, even tho they served to demonstrate the ideas.

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci +1

      @@l_t_m_f Understood!

  • @NostromoVA
    @NostromoVA Před měsícem +1

    Brilliant! You just got a new subscriber!

  • @macxike
    @macxike Před 6 měsíci +4

    Finally found an in-depth tutorial of how to solve tick problems, thank you! It would be great if you can follow up this tutorial with a tutorial of how to make use to Tick Groups. Everyone explains how it works, but its still unclear how to actually take advantage of this in a working project. Would love to see your examples of this.

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci +2

      I will make a note of this on my todo list and see if I can return to it in the future. It is a fairly uncommon need to have ticks needing to execute in specific orders.

  • @tonywood2283
    @tonywood2283 Před 17 dny +1

    Great content sir. Subscribed!

  • @kacktustoo
    @kacktustoo Před 6 měsíci +2

    That was incredibly informative thank you for this. I'm just starting unreal and understanding fundamentals like this is so important to me.

  • @PerryButler
    @PerryButler Před 27 dny

    Just put a Delay 0.1 or 0.05 or whatever interval you need right after the Tick so you don't have to refactor the code. If the Delay is still waiting, Tick won't do anything, it's only a boolean check happening on Tick. Timelines and other things are basically wrappers around the engine's core Tick, costing more memory to create those objects. Delay Tick seems more lightweight than any other timer method in blueprints, correct me if I'm wrong though!
    If it's a multiplayer game then watch out how you use Delays because they can cause replication to happen out of order which is confusing to debug. Particularly when replicating several changes in a row, and a Delay is in there, the variables might replicate out of order and cause an odd state. Other than that, I use a lot of Delays without seeing a problem.

  • @OverJumpRally
    @OverJumpRally Před 6 měsíci +1

    Great video! I'm also using a Tick Optimization Toolkit, a plugin that allows you to manage ticking elements, so they don't think if they are too further away or not visible on camera.

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci

      Thank you!
      Those kind of tools can be useful to disable ticks of actors that are too far away to be relevant. That saves some performance.
      But it is still important to make sure you don't have ticking actors if they don't need it because they will tick when near.

  • @abdulalgharbi8784
    @abdulalgharbi8784 Před 6 měsíci +1

    Thank you the be a better game dev is very very useful

  • @elitetechworks
    @elitetechworks Před 6 měsíci +1

    Great Tutorials :D thanks for sharing

  • @trollgasm
    @trollgasm Před 6 měsíci +2

    Another good one.

  • @9243672946729
    @9243672946729 Před 6 měsíci +1

    Nice thanks, that's very handy performance pattern.

  • @Mohit_N.R
    @Mohit_N.R Před 6 měsíci +2

    informative ✨

  • @franklingamedev
    @franklingamedev Před měsícem +1

    Thank you for this information, it's great! I have a question: Should I use Tick only to move things? For example: "SetActorLocation/Rotation/Scale" or "AddMovementInput (for pawns)"? Should this be the only use? What other options do I have? Thank you.

    • @LeafBranchGames
      @LeafBranchGames  Před měsícem +1

      Thanks! No, the rule of thumb is for things you needs to update often.

  • @linezgames3893
    @linezgames3893 Před 2 měsíci +1

    I love your work man, voice too helps a lot.
    wish people developed efficiently.
    crazy how hardware has massively improved but programmers/game designs have gotten way lazy in the past decade.
    please don't argue saying i'm wrong, I know what I'm talking about...

  • @beaverundercover3479
    @beaverundercover3479 Před 6 měsíci +1

    Thanks for the video. What is a good example of Tick usage?

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci

      My pleasure. Anything that needs a contineous updpate would be reasonable to have. So it can be a wide variety of things depending on the game. A specific example could be some custom camera movement.

    • @Drakuba
      @Drakuba Před 6 měsíci +1

      im making RTS, and for the gods of me couldnt figure out how not to use tick when updating cursor position, so i suppose that would be one. But there are ways how to make unit selection without tick, even tho with tick its much easier - that made me realize i played few RTS that had tick based unit selection since everytime i tried to select units you can see FPS dropping :P
      i also animated tank tracks using tick, but i read its possible to animate those using unit speed and not to use tick so ill be looking into that as well
      but just as Leaf said, physics and animations use tick for updating themselves and theres little to no way around it, best you can do is tick only when they actually move and not just constantly check for updates when they are not moving afaik

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci +1

      @@Drakuba Mouse cursor is a very good example. Because if a mouse cursor feels sluggish, that gives a very bad sensation to the user - so having it responsive is key for a good experience.

  • @GES1985
    @GES1985 Před 6 měsíci

    Should use event tick to control a platform in a floor is lava type puzzle, then give the player the frame rate controls in their settings. That would be an interesting / think outside of the box type situation

  • @fabulamcafee
    @fabulamcafee Před 6 měsíci +1

    i was only reading the title and thought "just never use this" lmao

  • @gokuvinod2850
    @gokuvinod2850 Před 6 měsíci

    hello Sir, is using structures better than using the standard variables for eg I have a player stats such as health, stamina, manna, etc so addiing current and max health to structures should be the way to go or just adding those to variables in BP_Component itself is fine or is there anything else i need to know of? Thank you for ur help!

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci +1

      It depends, it is not a straight forward thing I can answer. They are good in different aspects.
      For example if you have structure being sent through functions, then you will be sending all the data, even if you only make use of one of the stats in the function.
      You could use structures, or you could use classes, it depends on what you are going to use them for.
      You can probably start with what is the most convenient to begin with and then refactor later on if neeeded.

    • @gokuvinod2850
      @gokuvinod2850 Před 6 měsíci

      @@LeafBranchGames ohh ok then I'm not much familiar with structs so i'll stay away from it as of now. Thanks!

  • @GordonSeal
    @GordonSeal Před 4 měsíci +1

    Would it be bad practise, to use a timer instead of a tick, e.g. for physics simulation on an actor like add force, with a timer rate of 0.02 or some similiar low value?

    • @LeafBranchGames
      @LeafBranchGames  Před 4 měsíci +1

      Probably. You would likely want your physics to be as accurate as possible, unless you are trying to do it on a large scale. But even then you probably want to look into ISM, or HISMs or similar I think.

    • @GordonSeal
      @GordonSeal Před 4 měsíci

      @@LeafBranchGamesIsn't the physics simulation in Unreal always on an event tick though (in the background)? If I enable physics for a static mesh, I don't see an option to not use tick for the simulation itself.
      I guess my question was rather if using a timer on a low value like 0.02 makes sense, or if there are drawbacks to be doing this.

    • @LeafBranchGames
      @LeafBranchGames  Před 4 měsíci +1

      @@GordonSealThere is a cost for using a timer because you are essentially setting up delegate that triggers on completion. So if you have a timer with a very frequent update(as often as tick or near), then you probably losing more than you are gaining and should just use tick.

    • @GordonSeal
      @GordonSeal Před 4 měsíci

      @@LeafBranchGamesThank you for explaining it, that is very good to know!

  • @Fudolux
    @Fudolux Před 6 měsíci

    Thank You, UE/ Blueprint tutorials are very useful, CZcams is still dominated by Unity.

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci +1

      That is a reasonable since Unity has a larger marketshare.

  • @aleca8910
    @aleca8910 Před 6 měsíci +2

    That thumbnail is going to enforce the wrong idea of that using Tick is a bad practice itself.

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci +2

      Only if they don't watch the video.

    • @aleca8910
      @aleca8910 Před 6 měsíci +1

      @@LeafBranchGames That must be exactly what many do, because that weird idea is popular on every dev channel.

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci

      @@aleca8910 It is mostly about nuance. Using tick too frivolously comes at a cost, a cost not everyone understands. So I explain how it works so that they can better make the judgement on if tick is a good option or not, and if not - what alternatives you have.

    • @peevee5588
      @peevee5588 Před 6 měsíci +2

      Totally disagree. Great thumbnail and great video.

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci

      @@peevee5588 Thank you. :)

  • @starscream2092
    @starscream2092 Před 6 měsíci +3

    Hello, this may sound stupid or unimportant, but I or maybe many other people learn better with practical use cases. If you would want to reach more people (many beginners) you could create an ultra small project where you show the proper implementation of these systems. Player with health getting update on projectile dmg, stamina, and flashlight. 99% tutorials put these fundamental things in games on tick and call it a day. If i am asking for too much sorry. Its just me and my friend (beginners) were discussing this video and how you are right and it makes a lot of sense. Also we tried to get the best way to show ingame FPS for the player on the hud, and that is probably impossible without a tick.

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci +1

      There are things that are unavoidable or even should be on tick. Showing FPS for example is one such thing that could make sense. Now, you may not need to have it update every frame, so you could use a technique to make it less often, like a timer or a tick with interval. You have the get delta seconds node that you can use to calculate the FPS for that specific interval.
      The point is, Tick has its place, it is something that you should use for things that need frequent update, on every frame. But it is important to realize when you do not need it, and how you can work around it.

    • @TacTicMint
      @TacTicMint Před 6 měsíci +2

      Projectile damage should be triggered by the collision. Periodic updates like stamina should be done with a timer (Check out set timer by event) you can set it to a specific time like 0.5 seconds instead of per frame. Per frame is every 0.0166 seconds at 60 FPS. Usually you only want to use tick for things that are physics or visual and have to match the frame like location, scale and rotation. Maybe if you're changing color or opacity but that can be done on a timer.

  • @DEM1GOD7
    @DEM1GOD7 Před 6 měsíci

    15:48 "Redo this code completely" Nay Redo these nodes completely. you're not in code, you're in blueprints made up of code.

    • @LeafBranchGames
      @LeafBranchGames  Před 6 měsíci +1

      Blueprints is a visual scripting language that translates to bytecode which essentially calls on existing functions in C++. So even though the representation is visual it is no different than writing in text(C++) to call on those same functions. Disregarding overhead and such factors of course.