Master Unreal Engine: Understanding Hard and Soft References

  Рет қаралды 5,233

Danny Goodayle - Unreal Tutorials

Danny Goodayle - Unreal Tutorials

Күн бұрын

In this video, we'll be exploring the concept of hard and soft references in Unreal Engine. We'll be looking at how loading times can be improved by using hard references, and how memory usage can be reduced by using soft references.
If you're new to Unreal Engine or are looking to improve your game performance, this video is for you! By the end of this video, you'll have a better understanding of how hard and soft references work and be able to apply this knowledge to your own projects.
--
Links:
docs.unrealengine.com/4.26/en...
www.quodsoler.com/blog/unders...
dev.epicgames.com/community/l...
---
00:00 Whats the difference?
00:15 Example
01:01 Why this matters
02:00 Recommendations
02:25 Converting Hard to Soft pointer
05:49 Soft References in C++
09:44 Casts = References
12:24 Wrapping it up

Пікірлер: 76
@DanGoodayleUnreal
@DanGoodayleUnreal 8 ай бұрын
Trying something a little different, instead of a disembodied voice talking I wanted to have something on screen that was a bit more interesting to watch than whatever my mouse was pointing at. This was an experiment so let me know if it's working or not, if it's distracting / getting in the way from what I'm talking about let me know 😶
@chasesommer
@chasesommer 8 ай бұрын
I like seeing your beautiful face
@DanGoodayleUnreal
@DanGoodayleUnreal 8 ай бұрын
@@chasesommer 😅 thank you!
@acesonfire
@acesonfire 3 ай бұрын
I have been about to pull my hair out trying to wrap my mind around this, I have probably watched close to 30 different videos attempting to explain this concept. Yours is the one that finally made me get it. Thank you.
@DanGoodayleUnreal
@DanGoodayleUnreal 3 ай бұрын
That’s fantastic, thank you!
@draftdrifter5779
@draftdrifter5779 2 ай бұрын
Great video. I love the fact that you show both blueprints and C++. Hope you continue making more!:)
@DanGoodayleUnreal
@DanGoodayleUnreal 2 ай бұрын
Thanks, will do!
@SuperLordee
@SuperLordee 2 ай бұрын
Thank you for this video this was extremly helpful since you also showed in C++!
@DanGoodayleUnreal
@DanGoodayleUnreal 2 ай бұрын
Glad it was helpful!
@xultix
@xultix 8 ай бұрын
Just saying Thanks for these kinds of videos, definitely things I wasn't really thinking about as I started dabbling in unreal engine again so always good to know and expand my knowledge!
@DanGoodayleUnreal
@DanGoodayleUnreal 8 ай бұрын
Glad I can help! The engine is pretty huge but if you break it down into manageable chunks it's pretty awesome. Best of luck with your projects!
@unreal_metronomus678
@unreal_metronomus678 2 ай бұрын
Earned a sub. Really very well explained, thanks a lot!
@DanGoodayleUnreal
@DanGoodayleUnreal Ай бұрын
Awesome, thank you!
@Daniel-be6cj
@Daniel-be6cj 2 ай бұрын
This is great, I had changed some skeletal meshes I wanted to load to a soft reference but they weren't loading, the async load node was exactly what I needed. Thank you!
@DanGoodayleUnreal
@DanGoodayleUnreal 2 ай бұрын
Glad it could help!
@ThadeousM
@ThadeousM 5 ай бұрын
I'm just starting out and so far all the info I've coming into contact with suggest going straight to BP Interfaces rather that Casting so thank to folks like yourself for continuing the convo
@DanGoodayleUnreal
@DanGoodayleUnreal 5 ай бұрын
Interfaces are a great way to keep things decoupled, good luck with your projects!
@C4RL054321
@C4RL054321 7 ай бұрын
Great video Dan, I've recommended it to my team 😊
@DanGoodayleUnreal
@DanGoodayleUnreal 7 ай бұрын
Awesome, thank you!
@eduard2630
@eduard2630 6 ай бұрын
Briliant! Thank you so much for this particular video. After reading 5 pages long articles full of water with as much sense as "games made with Unreal Engine use RAM", it makes me uneasy, that the concept of hard/soft references technically could be explained in one sentence lol I've recommended this video to all my fellow UE devs just in case hehe
@DanGoodayleUnreal
@DanGoodayleUnreal 5 ай бұрын
Glad it was helpful!
@user-lo5um8zh8z
@user-lo5um8zh8z 7 ай бұрын
your video is greatest i've seen a couple of them and i've learned so much. Expecting for your gameplay ability series~
@DanGoodayleUnreal
@DanGoodayleUnreal 7 ай бұрын
Glad you like them!
@libertarianterminator
@libertarianterminator 7 ай бұрын
I was trying to get my head around using triggers in my VR project and I saw the notes that said casting is taxing. This video explained neatly how to do it right. Thank god I found this before I implemented too many features! Keep making videos about UE, you are great!
@DanGoodayleUnreal
@DanGoodayleUnreal 7 ай бұрын
Glad it was helpful!
@ethanwasme4307
@ethanwasme4307 7 ай бұрын
On the bright side, if you're already hard referencing the cast is near free xD
@draicor
@draicor 5 ай бұрын
This video was amazing, thank you mate
@DanGoodayleUnreal
@DanGoodayleUnreal 4 ай бұрын
Glad you enjoyed it!
@alexkulev352
@alexkulev352 6 ай бұрын
Very clear explanation. Gonna use this video every time I need to pitch the necessity of the soft refs to designers :D
@DanGoodayleUnreal
@DanGoodayleUnreal 6 ай бұрын
Glad it was helpful!
@vinreals5694
@vinreals5694 4 ай бұрын
A few spots that are not correct. Objects loaded through soft references won't stay in memory forever. If there is no hard reference pointing to that object, Garbage collection will step in and delete that object. That's why you don't see soft references get unloaded in source code. Loading assets synchronously is not always bad. That's where the loading screen comes in. Lyra uses it extensively to load in crucial assets for the shooter core.
@DanGoodayleUnreal
@DanGoodayleUnreal 4 ай бұрын
Heya, thanks for the comment, If you stash the handle from the streaming manager, you have to manually release it for the objects the then be GCd, that’s what I was getting at. If you store off hard references to the objects and don’t stash the handle, they will be GCd the moment the hard reference is removed. Sometimes you might want to preload a bunch of things but not necessarily keep them referenced directly, for example having a bunch of frequently loaded / unloaded equipment on a character. Preloading and stashing the handles allows for faster loading during gameplay. Sync loading assets isn’t always bad, but if you can asynchronously load you don’t block the game thread for an undetermined amount of time, allowing you to give the players some feedback on what’s happening. Of course if there is a static loading screen you may want to just sync load, but if it’s animating on the game thread (via UMG, which I think is -only- game thread) then you will have it freeze until the load is done.
@GarethNN
@GarethNN 4 ай бұрын
Great explainer, thank you!
@DanGoodayleUnreal
@DanGoodayleUnreal 3 ай бұрын
Thanks!
@ReubenAStern
@ReubenAStern 18 күн бұрын
C++ eh?! That's gonna make me subscribe!! For some reason every Windows IDE I use works for a while then tells me all my code failed. But I'll get back to learning C++ one day.
@ian_snyder
@ian_snyder 4 ай бұрын
Great info, thanks!
@DanGoodayleUnreal
@DanGoodayleUnreal 3 ай бұрын
Glad it was helpful!
@Whiskeysim
@Whiskeysim 7 ай бұрын
Good video, but you should check your audio levels. I had to crank my volume to like 85% just to be able to hear you. My average volume sits at 6% if that gives you an idea.
@DanGoodayleUnreal
@DanGoodayleUnreal 7 ай бұрын
Thanks for the feedback! I'll give normalising the levels a shot for the next video, I've been using headphones to review before hand so far, so that's probably the cause of it!
@Whiskeysim
@Whiskeysim 7 ай бұрын
​@@DanGoodayleUnreal Yeah doesn't change the quality of the video in anyway, but having to scale the sound so high makes notification sounds from like 'Discord' mildly fear inducing haha.
@DanGoodayleUnreal
@DanGoodayleUnreal 7 ай бұрын
@@Whiskeysim hah I totally get it! Honestly each video I'm trying to change something to improve things gradually over time, I'll give the audio more of a look on the next one's and see how people react to it. Thanks for your time letting me know, it really helps me figure out how to do all this 🫡
@julienpaul4899
@julienpaul4899 3 ай бұрын
Merci beaucoup !
@0xJarry
@0xJarry 7 ай бұрын
Great video and examples
@DanGoodayleUnreal
@DanGoodayleUnreal 7 ай бұрын
Thank you!
@Mr.Sunshine2023
@Mr.Sunshine2023 7 ай бұрын
wow, nice, thanks
@DanGoodayleUnreal
@DanGoodayleUnreal 7 ай бұрын
You are most welcome
@Borszczuk
@Borszczuk 9 күн бұрын
Can you please explain why (@4:38 +/-) you connected input of conversion pin to the "Montage to play" output and not to the Async Loader's "Complete" output? To my understanding, since the loader is async loader you would simply "fire" conversion pin too early, no?
@crispychicken143
@crispychicken143 7 ай бұрын
good stuff
@DanGoodayleUnreal
@DanGoodayleUnreal 7 ай бұрын
Thank you
@mangarookie
@mangarookie 16 күн бұрын
Hey Dan thanks a lot for the tutorial. I have a little question thou. When I async load a soft class reference, do I not need to get the handle and unload/cancel it? Also what will happen if I async load a soft class reference in a struct?
@MonderMurshed
@MonderMurshed 4 ай бұрын
Thank you! but i have 2 questions. 1 - Can the same actor or class be loaded in the memory more than once? because if it does i must study more about these things. 2- if i did everything in hard reference it means all my stuff will be loaded in the startup of the game (everything?) Thanks again for the video and i will be grateful to see your answers!.
@DanGoodayleUnreal
@DanGoodayleUnreal 3 ай бұрын
1) No, the actor class defaults object will only be loaded into memory once. At that point any soft references to that object will then point to that. 2) yes in theory if you had a single object referencing every asset you could. You can also inadvertently load more than you want if you aren’t careful with hard references (loading a UI element which has a hard ref to a character BP for instance would load that BP too)
@lespaul1507
@lespaul1507 4 ай бұрын
Thanks for the video. Im new and trying to learn all this stuff. My main character BP is like 400mb. Im trying to make sure nothing else references it to avoid them going from a 10mb BP to 410mb BP. But as soon as I connect them to a BPI, they are already 410mb. Maybe its the way im doing it, I have to play around with it more, but can you still make a hard reference with BPI? Maybe thats what im doing..
@DanGoodayleUnreal
@DanGoodayleUnreal 2 ай бұрын
What’s showing in the reference viewer for the asset?
@imyokoyoko
@imyokoyoko 5 ай бұрын
Can i use soft references to prevent the "Accessed None Trying To Read Property" Error messages? I have certain blueprints that, just for a moment, do that, then the asset loads and works properly.
@DanGoodayleUnreal
@DanGoodayleUnreal 3 ай бұрын
Soft references wouldn’t load the object implicitly, you have to manually load it. So if you wanted to use a function on it they would throw an error because it wouldn’t be loaded until you (or something else hard referencing it) loads the object first.
@Aantjack
@Aantjack 3 ай бұрын
So, for example, when I spawn in AI characters I would use hard refrences? What is a must use case for hard refs?
@DanGoodayleUnreal
@DanGoodayleUnreal 3 ай бұрын
Let’s say you have 100 different AI character types. You would create some sort of data asset to manage them, you then use soft references to all of them. Now to load that data asset you don’t then need to load all 100 AI characters (if they were hard refs you would have to). You could then take 5 of the characters and load their soft references into memory, then spawn those characters. Does that make sense?
@lospe85
@lospe85 5 ай бұрын
so, if i have a master Item blueprint (lets calle it BP_Item), parent of all items in the game. This BP_Item executes a "Get Data table Row" at some point, so it takes a DataTable as a hard reference, therefore loading the whole datatable into memory. Now let's say I have 20 items (children of the BP_Item class), does it means that the DataTable is being loaded 20 times in memory, using 20x memory usage? Or... if the DataTable is loaded for the first item to spawn, then the remaining 19 items will use that reference in already loaded in memory (no duplication)?
@DanGoodayleUnreal
@DanGoodayleUnreal 4 ай бұрын
It'd only be loaded into memory once
@lospe85
@lospe85 4 ай бұрын
@@DanGoodayleUnreal thanks for you answer!
@unreal_metronomus678
@unreal_metronomus678 Ай бұрын
Hi Dan. I´ve notived something strange. I´ve hooked a soft reference variable (anim montage) to a blueprint interface. In the bp that receives the interface message, I dont have to load the montage into memory, I can just pass it into the play montage node. Where does the anim montage get loaded?
@DanGoodayleUnreal
@DanGoodayleUnreal Ай бұрын
So the blueprint interface requires a hard ref and you are pass in a soft ref? If you try and do that it'll do a cast from soft to hard ref (in blueprint it'll look like a light blue dot changing to a darker blue dot). If the asset has been loaded previously (and is still loaded) it'll resolve to the correct asset, however if it hasn't been loaded it'll return a nullptr. This can lead to odd behavior in cooked builds, as you may load the asset without knowing in the editor (you can load an asset in the editor just by double clicking it), but in a cooked build that asset may not be loaded.
@unreal_metronomus678
@unreal_metronomus678 Ай бұрын
@@DanGoodayleUnreal Hi. Thanks for the reply. No, I passed a soft ref in the interface. In my player bp I defined the soft variable "deathanimmonatge" (and entered the anim montage) and hooked it up to a interface function (soft ref) . My gameplay abilty uses the interface to pick up the montage. But I can just hook up the interface node in my ability bp to the play montage node and the anim play without having to load the asset. I haven´t opened the montage in the editor, so I don´t know why I´m am not getting a nullpt :-/ . very odd..
@DanGoodayleUnreal
@DanGoodayleUnreal Ай бұрын
Could you grab some screenshots and post them here? Feel free to retract whatever you'd like, but it'll be helpful to debug things - and for anyone curious reading the comments :)
@GlassesAndCoffeeMugs
@GlassesAndCoffeeMugs Ай бұрын
@@unreal_metronomus678 Cook the game in development mode and log whether the soft ref is valid when you aren't expecting it to be. The editor is super unreliable when it comes to debugging stuff held in memory. If it is valid and it shouldn't be, there's a 100% chance the asset is being hard-referenced elsewhere, which you can use the reference viewer to check.
@unreal_metronomus678
@unreal_metronomus678 Ай бұрын
@@GlassesAndCoffeeMugs Yes, after restarting the computer for a couple of times, I I got an error message that the asset wasn’t loaded ( correct behaviour) . Hmm, yes, you are right about the editor being unreliable sometimes .. anyway, thanks for your reply.
@ethanwasme4307
@ethanwasme4307 7 ай бұрын
Something else i'm trying to tackle before scaling is circular dependencies
@DanGoodayleUnreal
@DanGoodayleUnreal 7 ай бұрын
Forward declare what you can, interfaces help too
@a2b2tv
@a2b2tv 8 ай бұрын
🥰
@DanGoodayleUnreal
@DanGoodayleUnreal 7 ай бұрын
🫡
@scislianlongshadow
@scislianlongshadow 2 ай бұрын
I do not have this damn async node, Unreal 5.3 I have in no blueprints been able to call this async node. What in the heck am I supposed to do.
@DanGoodayleUnreal
@DanGoodayleUnreal 2 ай бұрын
Which async node are you after? I think that was on the version before (can’t check right now I’m travelling)
@lorenfulghum2393
@lorenfulghum2393 Ай бұрын
your audio volume needs to come way up
@DanGoodayleUnreal
@DanGoodayleUnreal Ай бұрын
You aren’t the first person to say that! I’ve been trying new settings in later videos so hopefully that’s fixed. Hope the video itself was okay
Master Unreal Engine's Console Commands and CVars
11:46
Danny Goodayle - Unreal Tutorials
Рет қаралды 1,4 М.
UE5 Understanding hard and soft references - Be a better game dev
19:58
Climbing to 18M Subscribers 🎉
00:32
Matt Larose
Рет қаралды 30 МЛН
Как быстро замутить ЭлектроСамокат
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 14 МЛН
Why Dependencies are Bad and How To Avoid Them In Unreal Engine | UE5
26:40
SOFT Object References in Unreal Engine EXPLAINED
11:58
The Game Dev Cave
Рет қаралды 8 М.
I solved Unreal Engine's Package Size Problem...
14:35
Cobra Code
Рет қаралды 57 М.
Demystifying Soft Object References | Inside Unreal
1:27:51
Unreal Engine
Рет қаралды 83 М.
Asset Dependency Chains: The Hidden Danger | Unreal Fest 2022
40:48
Unreal Engine
Рет қаралды 13 М.
How to create Modular and Scalable UI systems in Unreal Engine
19:15
Отец подарил новый телефон дочке 🥺
0:36
Фильмы I Сериалы
Рет қаралды 1,3 МЛН
Sibling love 😥🥰👻
0:38
Ben Meryem
Рет қаралды 16 МЛН
Новый друг 🥰
0:31
ДОБРО ВОКРУГ
Рет қаралды 6 МЛН
Ela pulou em uma banheira cheia de coca?!😱 #shorts #challenge
0:22
Gabrielmiranda_ofc
Рет қаралды 13 МЛН
3 wheeler new bike fitting
0:19
Ruhul Shorts
Рет қаралды 43 МЛН