after you do the load thing for the soft object referenced variable, it will stay in memory as long as that variable still has that value. later on you can set the variable to some empty value and the space in memory for the class will be marked as "ready for garbage collection" and the engine will know that when it needs to free up some memory (garbage collection), that space in memory is a good candidate.
@sarfraz8533
7 ай бұрын
Unloading process? How to free memory when animation done playing.
@thegamedevcave
7 ай бұрын
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
7 ай бұрын
@@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
7 ай бұрын
just load them in when they are relevant, they should just get taken care off
@ryanjdevlin87
7 ай бұрын
U can use collect garbage node to force collection in blueprints It states it should only be done when a hang is acceptable.
@YoutubeAccountMan
4 ай бұрын
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
4 ай бұрын
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.
@ИгорьАлексеевич-м5м
3 ай бұрын
Откуда такая информация? Вы сами придумали или есть доказательства?
@joeypouladi
7 ай бұрын
Wow I had no idea about this and the potential impact it has on performance. Thank you, very informative👍
@thegamedevcave
7 ай бұрын
Glad to have helped out!!
@GiulianoVenturo
7 ай бұрын
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!!
@thegamedevcave
7 ай бұрын
i'm glad to hear that! :D
@chamussoide
3 сағат бұрын
Ehi There! Great Video. I have a question though: It's super clear what Hard and Soft Object references work to me, however I'm a bit confused about the Hard/Soft Class References. As you (and many others) said, an hard reference means that the referenced element is stored in memory. But what does it mean for a class? I'm my mind, as a c++ programmer, when we allocate memory we are actually creating an instance of a certain class, so what exactly is a class reference in blueprint and how it can be transposed in the "programming world"? The only thing that makes sense to me is that a class reference in memory is an instance of the interested class, but with all default values and it is used to create instances of that class (a.k.a. actors), probably with the usage of the copy constructor. I?m looking forward to the answer! Many thanks in advance!
@thegamedevcave
2 сағат бұрын
A class reference is a reference to the static class instead of to an object. So it works the same way as the object hard and soft reference for memory usage but instead you use it for things like spawning actors or constructing objects.
@chamussoide
Сағат бұрын
@@thegamedevcave awesome, It stars to be clearer to me, but a lot of fog disappeared ❤️
@akumadj7569
6 ай бұрын
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
6 ай бұрын
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
@vivegamespk
4 ай бұрын
today i really got actual concept of soft reference. Thanks
@davidbolt9370
4 күн бұрын
You said that to unload assets you'd need to learn to c++. Could you recommend somewhere where I can learn this? Currently managing audio and animation for a project, and managing when something need to be loaded and unloaded is really important, but I'm struggling to find learning resources
@thegamedevcave
4 күн бұрын
any loaded assets will unload together with the thing that loaded them. so if you have an object that loads a class , once said object is destroyed, so will the loaded class (or asset) this is usually enough. C++ has a few more functions to unload soft object pointers without needing to destroy the object that loaded it in, which can be useful, although a pretty niche scenario. It might be easier to just create a custom object that can handle the loading, then when you destroy that object, the loaded assets will also be taken care off instead of managing it through C++ Like i suggest in this video, especially if you dont have familiarity with C++ to begin with. Nonetheless, i have a whole playlist on my channel that can help you get started with C++, and from that point, you'd have to find the functionality through unreal docs (or more likely through people asking about it on the unreal forum), because i dont fully remember what files it requires and the names of the functions. In most scenarios i'd say you want to manage your assets inside the actors that'll be using them though, at which point unreal's own garbage collection will just take care of everything for you like i mentioned :)
@davidbolt9370
3 күн бұрын
@@thegamedevcave Thanks for the fast reply on an old video I'll check out the playlist once I'm more curious about c++, but the fact that destroying an actor unloads its related assets is incredibly useful to know! One quick thing though: Do you know if unloading a level stream will also unload it's associated assets? Maybe it's obvious but I would like to be sure
@thegamedevcave
3 күн бұрын
@@davidbolt9370 yes, the only time you have to worry about unloading something manually is if you load in a soft object reference like in this video in an actor that doesn’t get destroyed. Any other scenario, if some asset loads in another asset, it will also unload that 2nd assetbonce the first gets removed. That goes for blueprints, meshes, materials, textures and even levels. In 99% of cases Unreal takes care of all that for you. Only very rarely will it be needed to explicitly unload an asset (which is why it’s limited to c++ functionality because you don’t really need it)
@TheModExperiment
5 ай бұрын
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
@haxan4786
4 ай бұрын
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.
@TheFlyingEpergne
4 ай бұрын
so would you say if you know an actor is definitely going to be loaded in a level anyway its ok to have it as a hard reference? e.g i have multiple instances of a BP_House that is present pretty much throughout my entire game - that sort of thing would be ok to hard reference as it will always be loaded?
@thegamedevcave
4 ай бұрын
actually am planning to release a video about this very thing soon, in short : yes if you know something will be loaded anyway, there's no real harm in making a hard reference
@ИгорьАлексеевич-м5м
3 ай бұрын
А есть у вас опыт с подгрузкой data asset? И имеет ли смысл data asset и soft reference? 3) у меня есть spawn enemy actor и он спавнит противников в зависимости от растояния до игрока, использую world partitional и soft reference на mesh противников что бы перед добавлением их на уровень я вызываю async load mesh и назначаю противнику а когда уходу на дальнее растояние я использую destroy actor для противника, при destroy actor все же выгружается из памяти? 4) как еще можно отслеживать сколько памяти используется? У меня проблема в том что даже используя почти пустой уровень я замечаю иногда на 1 секунду просадку фпс с 60 до 40 и это заметно, не могу понять почему это происходит, в source map все вроде достаточно нормально
@ИгорьАлексеевич-м5м
3 ай бұрын
Возможно ли с вами как то связаться что бы задать пару вопросов по async load и оптимизации?
@BiZkiDD2
Ай бұрын
How did you connect the nodes at 6:36 ? Looks like magic!
@thegamedevcave
Ай бұрын
that's just an edit i'm afraid xd
@BiZkiDD2
Ай бұрын
@@thegamedevcave 🤣 oh man, and I just wasted half an hour researching "automatic node connection". Anyways, thanks for a great video!
@dougwarner59
3 ай бұрын
If an object exists in memory and you perform a "successful" cast (hard cast) it will have no ill effects because the object is already loaded into memory. that makes sense, but the part that confuses me is why is it bad to have a Cast just laying around, you could have as many cast as you want and there will be no negative side effects because it is already loaded in memory...unless each cast actually creates a copy of the object it is casting to in memory. Each time you cast you have to create memory big enough to hold the object. Or maybe we are talking about two different types of memory: RAM and ROM(Disc) memory. maybe a Hard Ref will place an object in RAM even if you might not want or need it there yet resulting valuable recourses being unnecessarily used. I am still not sure; could you explain Hard and Soft reference as the relate to RAM and Disc memory?
@thegamedevcave
3 ай бұрын
The issue is that hard references will ALWAYS keep the asset they’re referencing in memory, even if no object that uses them exists. So if you have a blueprint that has a hard reference to another blueprint that only appears in certain situations (like a specific level, only a handful of times in the game), it will now always be around in memory regardless of an object of that type actually exists. If you’re making a small game, that’s probably fine but this issue scales up pretty quickly… before you know it you’ve hard referenced so many things in so many different blueprints, you now have half the assets in your game loaded at all times, making your game use dozens of GB of ram.
@edgardsimon983
2 ай бұрын
i think that when u cast it update the current value of ur class too so yes the class is in memory already but with the previous value
@thegamedevcave
2 ай бұрын
@@edgardsimon983 the class itself doesn’t get updated. The actual objects of a class have their own values but a class itself is just a set of default (or static/shared) values. Casting loads those default values into memory, even if no objects of that class exist.
@edgardsimon983
2 ай бұрын
@@thegamedevcave ok but it actualy update the object value or whatever, it update something right ? cause i m not sure how it work
@thegamedevcave
2 ай бұрын
@@edgardsimon983 no, casting doesn't do anything to update any actual values. it takes in a reference and checks if the object you're referencing is also of the type you're acting to (so actor as input and it checks if that specific actor is a character). In order to do that, this blueprint now needs to know what a character is in order to do that check and afterwards, be able to access the information like variables or functions that exists on a character. so, it makes a hard reference to the character class. With c++ classes, that usually isn't an issue but when you cast to a blueprint class, that blueprint also has a lot of hard references usually to things like static meshes, which have references to materials and textures. Meaning that the casting to that blueprint loads ALL that into memory, just to be aware of what this class is, even if it isn't being used. This doesn't have anything to do with any values being updated in memory, that's just what happens when you change values on an object, and isn't really a problem in any way. The issue with casting comes in when , in order to be able to do a cast, you're loading blueprints and assets into memory like this.
@Siphonife
7 ай бұрын
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
7 ай бұрын
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
@stereocodes
7 ай бұрын
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
7 ай бұрын
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.
@owencoopersfx
7 ай бұрын
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
7 ай бұрын
top left there's a little settings menu that allows you to set how deep on both sides it should show the connections
@HoduAphrodite
4 ай бұрын
This was so much more comprehensive than similar content I've seen regarding soft references
@thegamedevcave
4 ай бұрын
Glad it was helpful!
@BlackskyRadio-x9s
4 ай бұрын
omg you need to use interfaces to stop all those hard references. lol
@thegamedevcave
4 ай бұрын
I got a video all about casting coming soon, why and when it is bad but also when it is fine to do.
@dreambadger
7 ай бұрын
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
7 ай бұрын
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
7 ай бұрын
@@thegamedevcaveThanks, yeah I did wonder. Maybe I'm trying to optimise the wrong thing. Cheers.
@MichaelGaskin
7 ай бұрын
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
7 ай бұрын
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
7 ай бұрын
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
@BaseRealityVR
7 ай бұрын
Can you not just use the Async Object out pin instead of hooking up the variable Directly, Or am I mistaken?
@thegamedevcave
7 ай бұрын
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
7 ай бұрын
Good Point@@thegamedevcave
@vrai_
5 ай бұрын
the annoying thing is async node doesn't return the exact class
@crossmr
Ай бұрын
Use interfaces and you never need the class.
@efekanssc6716
Ай бұрын
It's very unnecessary and bothersome.
@thegamedevcave
Ай бұрын
For small scale projects it’s not something to worry about. If you have lots of blueprint and lots of assets, this does become an issue
@efekanssc6716
Ай бұрын
@@thegamedevcave yeah if you making gta or something this is problem…
@efekanssc6716
Ай бұрын
@@thegamedevcave I shared your channel in UnrealEngineTurkiye forum. Your channel is important.
Пікірлер: 65