SOFT Object References in Unreal Engine EXPLAINED

Поділитися
Вставка
  • Опубліковано 22 тра 2024
  • You always hear people complain about how bad casting is, but then those same people rarely cover that even if you avoid a cast, if you have hard object references you're still off just ad badly, so today let's take a look at the issues with hard object reference and how to use soft references instead!
    Join the discord for any help you need! : / discord
    Join this channel to get access to perks:
    / @thegamedevcave
    support the channel and development over on patreon : / thegamingcaves
    Get personalized Coaching : www.fiverr.com/s/2P9GaN
  • Наука та технологія

КОМЕНТАРІ • 36

  • @GiulianoVenturo
    @GiulianoVenturo 2 місяці тому +4

    again this is why I like your videos. I know there are already some other videos explaining soft ref but in general I found in your content "tip and trick" for someone who already have time in unreal engine and it's useful info for having later. Thank you so much!!

  • @joeypouladi
    @joeypouladi 2 місяці тому +4

    Wow I had no idea about this and the potential impact it has on performance.
    Thank you, very informative👍

  • @vivegamespk
    @vivegamespk 14 днів тому

    today i really got actual concept of soft reference. Thanks

  • @akumadj7569
    @akumadj7569 2 місяці тому +1

    easy way around loading multiply assets is to use gameplay tags/string/enums to idetifiy which phase of attack or which attack needs to be loaded then use a select to run the branch you need. Allowing you to know chain 100 async load nodes but rather just call the ones you need.

    • @thegamedevcave
      @thegamedevcave  2 місяці тому

      I wouldn’t say that’s easy, if you want to load one of a few possible assets you can just pass in a soft obj ref variable instead

  • @HoduAphrodite
    @HoduAphrodite 17 днів тому

    This was so much more comprehensive than similar content I've seen regarding soft references

  • @haxan4786
    @haxan4786 12 днів тому

    comment for the algorithm!
    I was looking at the soft ref today, tried it and the compiler crashed, I shrugged and moved on. Now I know I have some optimizations I need to do -.-' I appreciate the priority list at the end there, actors and static meshes with textures.

  • @MichaelGaskin
    @MichaelGaskin 2 місяці тому

    Great video! Could you do an async load when a specific weapon is activated? Rather than when the player uses that ability? So, when the sword is your primary weapon, any montages needed for the sword weapon are pre-loaded before the actual ability is fired by the player.

    • @thegamedevcave
      @thegamedevcave  2 місяці тому +1

      For sure could! it's a bit of a puzzle on a case by case bases which assets you make hard and which you make soft references. in this case, instead of loading every animation through a soft reference like I do in the video, what would make more sense is to have the abilities themselves be soft references on the weapon that load on when the weapon it equipped. then the animations inside the abilities can still be hard references which will get loaded in and out with the weapon as a whole since the abilities would be soft references!

    • @MichaelGaskin
      @MichaelGaskin 2 місяці тому

      PERFECT! Your approach makes much more sense than mine (montages). The tools are there with UE5, its really about nailing the logic of using them. Thanks again! @@thegamedevcave

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

    1:00 OMFG!!! I click here and see then my idle animation have +100(!)mb unlike of other animation of walking and other things (+\- 10mb)
    Thank you for showing this tool :3

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

    the annoying thing is async node doesn't return the exact class

  • @dreambadger
    @dreambadger 2 місяці тому

    I keep all my montages in a map with enum selections. I could probably convert them to soft refs and have the selected montage feed into a single async node, which is in my function called Montage Picker. Then montage picker can have a pin to plug into the anim montage player. I'll test it out.

    • @thegamedevcave
      @thegamedevcave  2 місяці тому +2

      always good to try and to things like that if you can! but frankly, for the most part this kind of headache isn't worth the effort for animations because they're so small in size anyway, it's more relevant when you have references to assets like meshes and materials or whole other types of actors that you try to use soft references when you can. The animations in this video were mostly for demonstration purposes :)

    • @dreambadger
      @dreambadger 2 місяці тому

      @@thegamedevcaveThanks, yeah I did wonder. Maybe I'm trying to optimise the wrong thing. Cheers.

  • @owencoopersfx
    @owencoopersfx 2 місяці тому

    Thanks. How do you get the reference viewer to show the whole reference chain instead of just one reference layer at a time? Didn’t know that was a feature.

    • @thegamedevcave
      @thegamedevcave  2 місяці тому

      top left there's a little settings menu that allows you to set how deep on both sides it should show the connections

  • @YoutubeAccountMan
    @YoutubeAccountMan 16 днів тому

    It's tricky to know when to use this. It seems like a problem with this is that your game has to wait for soft object references to load while playing the game. Fine for something incredibly small, but you don't want your game to lag every time you have to play an animation. Also, soft object references are NOT freed up when your ability or whatever ends. In C++ you have to delete the pointer, but you can't do that in BP so it stays loaded until the game is closed. Soft references are one way you get memory leaks in BP iirc, so be careful.

    • @thegamedevcave
      @thegamedevcave  16 днів тому +1

      Assets referenced in an object will be removed from memory whenever that object is destroyed. Unreal's garbage collection takes care of any Uobject that is loaded but not referened anymore.
      As for lag, thats why you load these things async, its being loaded on a seperate thread so your game doesnt stutter, you just need to make sure that the code on your game thread doesnt try to use that asset before it gets fully loaded.

  • @stereocodes
    @stereocodes 2 місяці тому

    would sequence be better for async asset loading? also is there no such thing as async all or all settled in unreal/cpp? group all async calls into a single async listener that waits for all calls to finish?

    • @thegamedevcave
      @thegamedevcave  2 місяці тому

      the sequence node doesn't really do anything other than allow you to more neatly organize your nodes really. So if anything, for just putting all your Asynch loads in the first output of the sequence will help you get organized but the sequence node won't wait until those async tasks finish to move on (that's the whole point of an async task after all, you start it up and it completes in the background while the rest of your code keeps running)
      As far as loading multiple assets, i believe c++ has some way to do that which has a callback for when all assets in an array have finished loading but I haven't much looked into that as i've never really ran into needing to load in more than a handfull of soft references at a time.

  • @BaseRealityVR
    @BaseRealityVR 2 місяці тому

    Can you not just use the Async Object out pin instead of hooking up the variable Directly, Or am I mistaken?

    • @thegamedevcave
      @thegamedevcave  2 місяці тому +1

      you can! but the reason I dont do that is because it makes a lot of ugly confusing looking lines all over your blueprint. and you can't promote it to a variable because then you are making a hard reference again which makes the whole soft obejct reference and async loading obsolete. so just loading it and then using the soft reference variable is the cleanest way to do things and shouldn't give any issues if you make sure that by the time you use the reference it's actually loaded it (which also goes for if you were to use the output value from the async load node)

    • @BaseRealityVR
      @BaseRealityVR 2 місяці тому

      Good Point@@thegamedevcave

  • @Siphonife
    @Siphonife 2 місяці тому

    I understand streaming and why its useful but in 99% of scenarios I struggle find good reason for where and when its "OK" to have to wait for an object. If its not time sensitive then its cosmetic and can async load. If its not cosmetic then I need that object now to effect the game and async loads are going to delay the gameplay making a laggy mess. Lemme know what you think if you see this. What are good ways to load async and bad ways to load async.

    • @thegamedevcave
      @thegamedevcave  2 місяці тому

      it's a matter of choosing the most efficient points to turn into soft objects. you could turn all your asset references soft but that then ends up with having to manually load in a LOT of assets (like in this video).
      Instead, if we take my example in this video, what would be a better way to do it is to make the gameplay abilty itself a soft reference, that way it, and all the hard references (which includes meshes, particles and material) in it get loaded in when I want. so when the ability becomes possible to use, i async load it, while all the abilities that aren't possible to use at any given time won't be loaded, but i'll still have references to them.
      For another random exmaple. say you'remaking a pokemon game. You can have a soft reference to your pokemon class so you have a simple variable to acces it through on the player (or player controller more likely) but you only load that in when the actual pokemon is spawned into the world

  • @sarfraz8533
    @sarfraz8533 2 місяці тому

    Unloading process? How to free memory when animation done playing.

    • @thegamedevcave
      @thegamedevcave  2 місяці тому

      there isn't a way in blueprint to unload manually. when the object that loaded in the asset is destroyed it'll free up the memory again and otherwise unreal's garbage collection will also try it's best to unload once it think you are no longer using those assets. Manually unloading is a c++ only thing and for the most part not something you usually need to worry about.

    • @sarfraz8533
      @sarfraz8533 2 місяці тому

      @@thegamedevcave I am playing different animation montage again and again around 100 Anim 100 times using soft reference and load asset method called , how to profile this to check memory stack and not causing issue?

    • @thegamedevcave
      @thegamedevcave  2 місяці тому

      just load them in when they are relevant, they should just get taken care off

    • @ryanjdevlin87
      @ryanjdevlin87 2 місяці тому

      U can use collect garbage node to force collection in blueprints It states it should only be done when a hang is acceptable.

  • @user-os6gi9sn8k
    @user-os6gi9sn8k 10 днів тому

    omg you need to use interfaces to stop all those hard references. lol

    • @thegamedevcave
      @thegamedevcave  10 днів тому

      I got a video all about casting coming soon, why and when it is bad but also when it is fine to do.