Тёмный

SOFT Object References in Unreal Engine EXPLAINED 

The Game Dev Cave
Подписаться 18 тыс.
Просмотров 9 тыс.
50% 1

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

Наука

Опубликовано:

 

27 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 43   
@GiulianoVenturo
@GiulianoVenturo 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!!
@thegamedevcave
@thegamedevcave 4 месяца назад
i'm glad to hear that! :D
@joeypouladi
@joeypouladi 4 месяца назад
Wow I had no idea about this and the potential impact it has on performance. Thank you, very informative👍
@thegamedevcave
@thegamedevcave 4 месяца назад
Glad to have helped out!!
@akumadj7569
@akumadj7569 3 месяца назад
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 3 месяца назад
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 Месяц назад
This was so much more comprehensive than similar content I've seen regarding soft references
@thegamedevcave
@thegamedevcave Месяц назад
Glad it was helpful!
@vivegamespk
@vivegamespk Месяц назад
today i really got actual concept of soft reference. Thanks
@TheFlyingEpergne
@TheFlyingEpergne 29 дней назад
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
@thegamedevcave 28 дней назад
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
@user-li7ce3fc3z
@user-li7ce3fc3z 25 дней назад
А есть у вас опыт с подгрузкой 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 все вроде достаточно нормально
@user-li7ce3fc3z
@user-li7ce3fc3z 25 дней назад
Возможно ли с вами как то связаться что бы задать пару вопросов по async load и оптимизации?
@owencoopersfx
@owencoopersfx 3 месяца назад
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 3 месяца назад
top left there's a little settings menu that allows you to set how deep on both sides it should show the connections
@MichaelGaskin
@MichaelGaskin 4 месяца назад
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 4 месяца назад
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 4 месяца назад
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
@stereocodes
@stereocodes 3 месяца назад
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 3 месяца назад
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.
@vrai_
@vrai_ 2 месяца назад
the annoying thing is async node doesn't return the exact class
@dreambadger
@dreambadger 4 месяца назад
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 4 месяца назад
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 4 месяца назад
@@thegamedevcaveThanks, yeah I did wonder. Maybe I'm trying to optimise the wrong thing. Cheers.
@TheModExperiment
@TheModExperiment 2 месяца назад
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
@YoutubeAccountMan
@YoutubeAccountMan Месяц назад
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 Месяц назад
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.
@user-li7ce3fc3z
@user-li7ce3fc3z 25 дней назад
Откуда такая информация? Вы сами придумали или есть доказательства?
@BaseRealityVR
@BaseRealityVR 3 месяца назад
Can you not just use the Async Object out pin instead of hooking up the variable Directly, Or am I mistaken?
@thegamedevcave
@thegamedevcave 3 месяца назад
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 3 месяца назад
Good Point@@thegamedevcave
@haxan4786
@haxan4786 Месяц назад
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.
@Siphonife
@Siphonife 3 месяца назад
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 3 месяца назад
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
@dougwarner59
@dougwarner59 День назад
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
@thegamedevcave День назад
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.
@sarfraz8533
@sarfraz8533 4 месяца назад
Unloading process? How to free memory when animation done playing.
@thegamedevcave
@thegamedevcave 4 месяца назад
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 4 месяца назад
@@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 4 месяца назад
just load them in when they are relevant, they should just get taken care off
@ryanjdevlin87
@ryanjdevlin87 4 месяца назад
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 Месяц назад
omg you need to use interfaces to stop all those hard references. lol
@thegamedevcave
@thegamedevcave Месяц назад
I got a video all about casting coming soon, why and when it is bad but also when it is fine to do.
Далее
Function and Macro Libraries
11:33
Просмотров 1,2 тыс.
Самоприкорм с сестрой 😂
00:19
Просмотров 208 тыс.
How to Optimize Performance in Unreal Engine 5
17:40
Просмотров 20 тыс.
I solved Unreal Engine's Package Size Problem...
14:35
Soft Object References | Unreal Engine
18:37
Просмотров 1,7 тыс.
AI Learns to steal
17:23
Просмотров 327 тыс.
What does a Game Engine actually do?
16:45
Просмотров 141 тыс.
Optimizing my Game so it Runs on a Potato
19:02
Просмотров 439 тыс.
GAME ENGINE DEVELOPER Reacts to UNREAL ENGINE 5 Demo
30:56
Create Modular Designs With Enums In Unreal Engine 5
24:41
Tierlisting the BEST (and worst) GAME ENGINES
33:51
Просмотров 200 тыс.