Unreal 4 Threading - Running a Task on a Worker Thread

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ต.ค. 2024
  • In this tutorial we will use C++ with Unreal Engine 4 to get a backbround task running via the thread pool system.

ความคิดเห็น • 44

  • @jaybabcock9123
    @jaybabcock9123 2 ปีที่แล้ว +1

    Man I spent like 7 hours straight trying to figure this out on my own. Should have just sat through this video when I first opened it.

  • @alessandroameni
    @alessandroameni 5 ปีที่แล้ว +5

    You really saved my life with this video! I'll be grateful to you forever! ;-)

  • @jonlangford5224
    @jonlangford5224 6 ปีที่แล้ว +3

    Thank you for the tutorial! Really informative and easy to understand

  • @AliziaKaline
    @AliziaKaline ปีที่แล้ว

    Thank for the video. I don't know if it was intentional to increase the number of calculations, but to test prime or not, you can just store previous primes and test them only, no need to test all integer until x/2 ;)

  • @Melandowski
    @Melandowski 4 ปีที่แล้ว +1

    Muchisimas gracias por la informacion, mi problema no solo era hacer cosas en segundo plano si no leer datos (de XML) y pasarselos al hilo principal una vez terminada la ejecucion para básicamente hacer una pantalla de carga con todas las de la ley. Gracias a tu video y a 2 o 3 cosas más he podido implementarlo. Saludos!

  • @whiteowleducation
    @whiteowleducation 2 ปีที่แล้ว

    Good video. Thanks for putting this together.

  • @MrZadocH
    @MrZadocH 5 ปีที่แล้ว

    good i was learning how to implement but your example is the best i found thanks for it

  • @hongwangg
    @hongwangg 4 ปีที่แล้ว +1

    Is it possible to check whether the task is finished in the main thread? Since I need to retrive the calculated data from the task and call another function

  • @pwndulquiorra
    @pwndulquiorra 5 ปีที่แล้ว +9

    Okay, so this tutorial is pretty good but, for the purposes of optimization in my own game, I want to know the method for building the worker thread to work to work on long running or perpetual tasks. And since this tutorial specifically states to not do that with this one, I was wondering how to program a worker thread that could do just that.
    Thank you and have a good day.

    • @claysutton6597
      @claysutton6597 3 ปีที่แล้ว

      Sorry to be so off topic but does anybody know of a trick to log back into an instagram account..?
      I stupidly forgot the account password. I appreciate any tricks you can offer me

    • @bobbybrantley8298
      @bobbybrantley8298 3 ปีที่แล้ว

      @Clay Sutton instablaster :)

    • @claysutton6597
      @claysutton6597 3 ปีที่แล้ว

      @Bobby Brantley Thanks for your reply. I got to the site on google and Im trying it out now.
      I see it takes a while so I will reply here later with my results.

    • @claysutton6597
      @claysutton6597 3 ปีที่แล้ว

      @Bobby Brantley It did the trick and I finally got access to my account again. Im so happy!
      Thanks so much you really help me out :D

    • @bobbybrantley8298
      @bobbybrantley8298 3 ปีที่แล้ว

      @Clay Sutton happy to help :D

  • @Blueshark905
    @Blueshark905 6 ปีที่แล้ว +1

    This was very interesting. Thank you for sharing your knowledge friend :)

  • @ivansologubov5631
    @ivansologubov5631 5 ปีที่แล้ว

    Yes, a great tutorial. Thanks for creating it!

  • @brianlaflamme1948
    @brianlaflamme1948 4 ปีที่แล้ว

    Good stuff! thanks for the knowledge! I definitely need this for my Ai Pathfinding Spline system.

  • @CyberWolf755
    @CyberWolf755 6 ปีที่แล้ว

    Superb tutorial!
    Could you go provide us with the classes that you made and if there is some good documentation for beginners for threading?

    • @gamedevsocietybu6179
      @gamedevsocietybu6179  6 ปีที่แล้ว

      If I can find the UE4 project then I'll zip it up and link it for you. I think it will be on my work PC though so I cannot check right now.

  • @ZangJM
    @ZangJM 5 ปีที่แล้ว +6

    what if a want to fire a event on the blueprint when the background task finish?

    • @VladyVeselinov
      @VladyVeselinov 3 ปีที่แล้ว

      you can use delegates for that forums.unrealengine.com/community/community-content-tools-and-tutorials/13915-tutorial-creating-and-using-delegates-c-and-accessing-them-in-blueprints

  • @angrybonobro8711
    @angrybonobro8711 3 ปีที่แล้ว

    Very helpful! Thank you very much

  • @isaackershnerART
    @isaackershnerART 2 ปีที่แล้ว

    Thank you! im fairly new to c++ but how would i go about outputing the parameters through the blueprint function? say pass the prime values found into an array in BP...

  • @calmsh0t
    @calmsh0t 5 ปีที่แล้ว +2

    Can I let the task return a value?

  • @LudwigvanBeethoven2
    @LudwigvanBeethoven2 4 ปีที่แล้ว

    How can I make callbacks for the caller thread?
    I managed to do it with
    AsyncTask(ENamedThreads::GameThread, [OnReportProgress = OnReportProgress ]() { OnReportProgress.ExecuteIfBound(....) })
    this works. but sometimes I want to cancel the running work and run a new work with new parameters. when I cancel the thread, things go wrong and i get access violation errors.

  • @ZangJM
    @ZangJM 5 ปีที่แล้ว

    Thank you very helpfull tutorial!

  • @usernotfound.3837
    @usernotfound.3837 3 ปีที่แล้ว

    what a fucking legend you are

  • @MarkusRomulusMaximus
    @MarkusRomulusMaximus 5 ปีที่แล้ว

    Hey there, nice tutorial! Any idea why TStatID throws identifier undefined? I updated the includes for IWYU standard for UE 4.22 with #include "Runtime/Core/Public/Stats/Stats.h", but I am not having any luck there.

    • @weekendum7880
      @weekendum7880 5 ปีที่แล้ว

      Just in case you haven't figured it out yet, it's because it's not "D" but "d"

    • @MarkusRomulusMaximus
      @MarkusRomulusMaximus 5 ปีที่แล้ว

      @@weekendum7880 Mother of god! Thanks you so much!

  • @umeshramchandani9033
    @umeshramchandani9033 6 ปีที่แล้ว

    Thanks and this was really helpful !!! I would love a tutorial on the niagara system also I crashed into a problem where I need a 2d array for textures in material. Are there any ways to add it ourselves ?

    • @gamedevsocietybu6179
      @gamedevsocietybu6179  6 ปีที่แล้ว

      I will hopefully be making more tutorials soon, and can cover Niagara then.
      I don't think you can make 2D arrays. You might be able to have an array of a struct which itself contains an array, or have a normal array then you "step" over as though it was 2D.

    • @umeshramchandani9033
      @umeshramchandani9033 6 ปีที่แล้ว

      @@gamedevsocietybu6179 there is a mention of it in the documentation but I have no idea how to use it so I think I need to put everything in one image and access from it :(

  • @calmsh0t
    @calmsh0t 5 ปีที่แล้ว

    What do I need to do to use FNonAbondableTask? using it throws a compile error "undefined class"

    • @gamedevsocietybu6179
      @gamedevsocietybu6179  5 ปีที่แล้ว

      Sorry for late reply, it is "FNonAbandonableTesk", not "FNonAbondable".

  • @dipamphoenix760
    @dipamphoenix760 5 ปีที่แล้ว

    Can you show how to do SaveGame Asynchronously, I mean saving the game in background and gameplay will continues at the same time

    • @gamedevsocietybu6179
      @gamedevsocietybu6179  5 ปีที่แล้ว

      I haven't tried it, but can you call the CreateSaveGame and SaveGameToSlot functions in UGameplayStatics (I think) from the background thread DoWork function?

  • @Nighta90
    @Nighta90 6 ปีที่แล้ว

    why do primesearchtask have to have int32 as an output?

    • @gamedevsocietybu6179
      @gamedevsocietybu6179  6 ปีที่แล้ว +1

      Not sure which int32 you mean by "output", do you mean the int32 that gets passed to the constructor?
      That is just there so we can pass a number to our class telling it how many prime numbers to find, otherwise it could just run forever. If you mean why is it "int32" rather than just "int" that is because the engine likes you to specify what type of int you mean, normal "int" do not show up in Blueprint but "int32" do.

  • @Metalwrath2
    @Metalwrath2 4 ปีที่แล้ว

    you are not using UE4 naming convention...