Watch this if you've never tried JOBS in Unity (Tutorial)

Sdílet
Vložit
  • čas přidán 5. 06. 2024
  • Show your Support & Get Exclusive Benefits on Patreon (Including Access to this tutorial Source Files + Code) - / sasquatchbgames
    Join our Discord Community! - / discord
    --
    JOBS are incredibly easy to schedule and can double (or sometimes more) your FPS depending on your use case. This system allows you to code safe-multi-threaded code for your games.
    I hope you enjoy!
    --
    Timestamps:
    00:00 - Introduction
    00:21 - Scene explanation
    01:03 - optimizing the enemy movement into a manager
    02:28 - JOBS explanation and setup
    03:36 - Setting up the JOBS struct
    06:51 - Scheduling a JOB
    08:33 - Using IJob and getting data from Job
    ---
    In need of more Unity Assets? Using our affiliate link is a great way to support us. We get a small cut that helps keep us up and running: assetstore.unity.com/?aid=110...
    ---
    Looking for some awesome Gamedev merch? - sasquatchbgames.myspreadshop....
    ---
    Who We Are-------------------------------------
    If you're new to our channel, we're Brandon & Nikki from Sasquatch B Studios. We sold our house to start our game studio, and work full time on building our business and making our game, Samurado.
    Don't forget to Subscribe for NEW game dev videos every Monday & Thursday!
    Wishlist Samurado!
    store.steampowered.com/app/23...
    Follow us on Twitter for regular updates!
    / sasquatchbgames
    #unitytutorial #unity2d #unity3d
  • Hry

Komentáře • 22

  • @naolshow
    @naolshow Před 20 dny +5

    The overhead at the end is not from job side, you are not disposing the rotation native array.
    And also you should not allocate and dispose the arrays each time since you are using the Persistent allocator, so either keep their reference by creating them at awake and disposing them in on destroy or simply allocate them and dispose them in update with a temporary allocator.

  • @majin2909
    @majin2909 Před 19 dny +3

    I know you since 1k subs, I am glad u didn't gave up and are that far on youtube, hope you are making a good living now, at least good enough to survive

  • @RobLang
    @RobLang Před 20 dny +2

    Really cool overview. Really appreciated the look at 15,000 individual jobs because I think the overhead would catch many out!

  • @b5fan504
    @b5fan504 Před 8 dny

    A good video. I suspect some people may benefit from clarity that, essentially, every time you say 'thread' you could say 'core'. That's what you're allowing here; to spread more work across more CPU cores. I also like that you touched on their being no free lunch; it comes with its own overhead as everything does.

  • @janseenvideogaming
    @janseenvideogaming Před 17 dny

    Okay.. Im going to give this another shot. I need to start showing viewers how to make cool games and get more viewers. tough. Great video man

  • @TheArghnono
    @TheArghnono Před 20 dny +1

    Excellent tutorial!

  • @OIndieGabo
    @OIndieGabo Před 19 dny

    Just to add my take on "why 2 libraries for Jobs exist" and also why we keep seeing libraries (namespaces) with the same name.
    I am not sure if this is exactly the case but the JOBS library is an isolated solution. It might not necesserally been written to work solely for the UnityEngine. It is a solution on multithreading in a specific scenario. So you have the solution "Unity/Jobs" (using slashs so youtube does not mistake it with a link). It contains everything to make Jobs work.
    And then you need an implematation that actually takes advantage of that system and applies its usage in the way it needs to its own solution. That's why you have the "UnityEngine/Jobs".
    It is basically the UnityEngine having an implementation on how to use the Jobs library, wich happens to be made by Unity (the company).

  • @user-uk9er5vw4c
    @user-uk9er5vw4c Před 4 dny

    nice content, thanks!

  • @AlexHosseini
    @AlexHosseini Před 20 dny

    Oh boi that was a nice explanation.

  • @danielwertz8724
    @danielwertz8724 Před 20 dny

    Im a godot developer but love your videos. Feel like i still got a little out of it. Helps that I use c# in my day job and use threading frequently. Thanks for the vid!

  • @Dragoncro0wn
    @Dragoncro0wn Před 20 dny +1

    Is it a bad idea to make the thread function like an update loop? Always running in the background doing its own tasks

  • @PhiLudo
    @PhiLudo Před 20 dny

    cool stuff

  • @redragon1229
    @redragon1229 Před 20 dny

    Cool video. I want to point out that although the ~x2 boost in your example does not look that impressive, actually, excluding rendering and other processes, Jobs can be HUNDREDS of times faster than the same single-threaded calculations. In this example the difference is not so significant because, I think, most of the performance hit is the rendering.
    Also, as @naolshow pointed out: this can be further optimized.

  • @user-rm2pj9jf8s
    @user-rm2pj9jf8s Před 20 dny

    I love it

  • @privatdetektivenkant5975
    @privatdetektivenkant5975 Před 19 dny +1

    Give me more!!!!!

  • @Coco-gg5vp
    @Coco-gg5vp Před 20 dny

    First

  • @GostGostcic
    @GostGostcic Před 19 dny +1

    this video is so bad, he could make this code 10x faster with jobs but he made so many mistakes in the video lol

    • @OIndieGabo
      @OIndieGabo Před 19 dny +5

      This comment means nothing if you are not pointing out how the solution would actually be improved. There is no harm on pointing mistakes out and explaining them so everybody can grow on it.
      What you did here is just offensive. And if this is was your intention it becomes clear why we should not listen to what you are saying and just ignore you in the future.

    • @GostGostcic
      @GostGostcic Před 18 dny

      @@OIndieGabo [ReadOnly] works only on native containers not the normal variables, boid Transforms should have null parent (this is extremely important) and updated only with TransformAccess.SetLocalPositionAndRotation(...), then he should show profiler because this is not the bottleneck (because can handle 100k+ updates per frame easily), he is doing something else wrong. i could go on... but the point is, dont watch this, he is missing the point of the JOBS and what they do.

    • @ehabelbwab1783
      @ehabelbwab1783 Před 2 dny

      @@OIndieGabo Agree