UE5 Understanding hard and soft references - Be a better game dev

LeafBranchGames
11 Dec 202319:57

Summary

TLDRIn this episode of 'Being a Better Game Dev,' the focus is on hard and soft references in game development, specifically within Unreal Engine. The video explains the difference between the two, with hard references loading all dependencies into memory, which can lead to high memory usage, while soft references only load assets when needed, reducing memory footprint. The tutorial demonstrates how to use both types of references, the impact on memory, and how to use interfaces and components to manage dependencies efficiently. The host also discusses the trade-offs between speed and memory usage, offering practical advice for optimizing game assets.

Takeaways

  • 🔗 Hard references in Unreal Engine load all dependencies into memory when an asset is loaded, which can increase the memory footprint.
  • 🔗 Soft references allow for assets to be loaded into memory on demand, reducing unnecessary memory usage.
  • 🔗 The memory footprint of an asset can be viewed using the 'Size Map' feature in Unreal Engine, which helps in understanding memory usage.
  • 🔗 Hard references can lead to a cascading effect where multiple assets are loaded into memory, even if they are not immediately needed.
  • 🔗 Soft references are indicated in the reference viewer with a purple line, as opposed to the white line for hard references.
  • 🔗 Interfaces can be used to interact with assets without creating hard references, thus avoiding unnecessary memory load.
  • 🔗 Components can be utilized to offload functionality and reduce hard reference dependencies within assets.
  • 🔗 Hard references provide faster access times since the assets are always loaded into memory, but at the cost of increased memory usage.
  • 🔗 Soft references require additional management to ensure assets are loaded into memory when needed, but they help in reducing the initial memory footprint.
  • 🔗 The choice between hard and soft references depends on the specific requirements of the game assets and the desired balance between memory usage and access speed.

Q & A

  • What are hard references in the context of game development?

    -Hard references are direct links to assets or objects within a game engine, such as Unreal Engine. When a blueprint or asset has a hard reference to another asset, the engine loads that asset into memory, ensuring it's available at runtime. This can lead to increased memory usage if not managed properly.

  • How do soft references differ from hard references?

    -Soft references do not force an asset to be loaded into memory at the start. Instead, they allow for lazy loading, where the asset is only loaded when specifically called for, thus potentially reducing the initial memory footprint of a game.

  • What is the memory footprint of an asset with hard references?

    -The memory footprint of an asset with hard references is larger because all referenced assets are loaded into memory when the main asset is loaded, regardless of whether they are currently needed or not.

  • How can you check the memory footprint of assets in Unreal Engine?

    -In Unreal Engine, you can check the memory footprint of assets using the 'Size Map' feature, which provides a detailed breakdown of the memory usage for each asset and its components.

  • What is the Reference Viewer in Unreal Engine and what does it show?

    -The Reference Viewer in Unreal Engine shows the dependencies of a selected asset, with hard references depicted by white lines. It helps developers understand which assets are being referenced by the selected asset and which assets reference it.

  • How can interfaces be used to avoid hard references in game development?

    -Interfaces can be used to avoid hard references by allowing for communication between assets without directly linking them. This way, an asset can call a function or event on another asset that implements the interface, without needing a hard reference to that specific asset.

  • What is the impact of having many hard references on a game's performance?

    -Having many hard references can lead to increased memory usage and potentially slower performance, as the game engine loads all referenced assets into memory, even if they are not currently in use.

  • How can you manage hard references to optimize memory usage in game development?

    -To optimize memory usage, developers can use soft references, implement interfaces, or utilize components to offload functionality. This allows for more control over when and how assets are loaded into memory.

  • What is the difference between object references and class references in Unreal Engine?

    -Object references are direct links to instances of classes, while class references are links to the class itself. Object references create hard references, whereas class references can be used to create either hard or soft references, depending on the context.

  • How do soft object references and soft class references work in Unreal Engine?

    -Soft object references and soft class references in Unreal Engine allow for referencing assets without loading them into memory immediately. They can be used to load assets on demand, reducing the initial memory footprint but requiring additional management to ensure assets are loaded when needed.

Outlines

00:00

🎮 Introduction to Hard and Soft References in Game Development

This paragraph introduces the topic of hard and soft references in game development, specifically within the context of Unreal Engine. The narrator discusses the impact of these references on the memory footprint of game assets. The video aims to explore how these references function, their advantages and disadvantages, and how they can be managed to optimize memory usage. An example is given using a third-person character and a helicopter asset from the Vigilante asset set, which is added to demonstrate the concepts. The reference viewer in Unreal Engine is highlighted as a tool for visualizing these dependencies.

05:01

🔗 Understanding Hard References and Their Impact on Memory

The second paragraph delves into the concept of hard references. It explains that hard references in Unreal Engine cause all dependent assets to be loaded into memory when the main asset is loaded. This is illustrated by adding a helicopter asset to a third-person character, which results in an increase in the memory footprint as observed in the size map. The paragraph also discusses the reference viewer, which shows the dependencies and how they are loaded into memory, leading to potential memory inefficiencies if not managed properly.

10:02

🔄 Transitioning to Soft References for Memory Optimization

The third paragraph introduces soft references as a way to manage memory more efficiently. Soft references allow for the referencing of assets without immediately loading them into memory, which can help reduce the overall memory footprint. The narrator demonstrates this by creating a soft reference to the helicopter asset within the third-person character blueprint. This approach requires manual loading of the asset when needed, which is shown to be done asynchronously. The difference in the reference viewer between hard and soft references is also highlighted, with soft references depicted in a different color to indicate their nature.

15:03

🔄 Utilizing Interfaces and Components to Avoid Hard References

The final paragraph discusses strategies for avoiding hard references, such as using interfaces and components. Interfaces allow for communication with assets without creating a direct reference, thus avoiding unnecessary memory loads. The narrator demonstrates this by creating an interface for the helicopter asset and using it within the third-person character blueprint. This approach keeps the memory footprint low while still allowing interaction with the asset. The paragraph concludes with a summary of the benefits and drawbacks of hard versus soft references, emphasizing the importance of managing these references to balance memory usage and performance.

Mindmap

Keywords

💡Hard References

Hard references in the context of the video refer to the strong ties that certain assets or objects have to one another within a game engine like Unreal Engine. When an asset has a hard reference to another, it ensures that the referenced asset is loaded into memory whenever the primary asset is loaded. This is crucial for functionality but can lead to increased memory usage, as seen when the third person character blueprint has hard references to other assets, causing them to be loaded into memory regardless of whether they are currently needed or not.

💡Soft References

Soft references are a type of reference in game development that allows for more flexibility in memory management compared to hard references. They do not force the referenced asset to be loaded into memory immediately upon the loading of the primary asset. Instead, they can be loaded on-demand. In the video, soft references are used to manage the memory footprint of assets like the helicopter, which is only loaded into memory when explicitly required, thus saving memory resources until necessary.

💡Memory Footprint

Memory footprint in the video script refers to the amount of memory used by an asset or a game object. It is an important consideration in game development as it directly impacts the performance and efficiency of the game. The video discusses how hard and soft references can affect the memory footprint, with hard references potentially increasing it due to the preloading of referenced assets, while soft references can help in managing it more effectively.

💡Blueprints

Blueprints in the video are visual scripting tools used in Unreal Engine to design and prototype game mechanics without writing traditional code. They are used to create various game objects like characters and vehicles. The video explains how blueprints can have hard or soft references to other assets, which affects how these assets are managed in memory.

💡Asset

An asset in the video refers to any object, model, or piece of data that is used in a game, such as a character model, a texture, or a sound file. Assets are crucial for the game's content and are managed through references. The video discusses how different types of references (hard or soft) can impact how these assets are loaded into memory.

💡Reference Viewer

The reference viewer is a tool within Unreal Engine that allows developers to visualize the dependencies between assets. It shows which assets a particular blueprint or asset references (hard references) and which assets reference it (soft references). The video uses the reference viewer to demonstrate how hard and soft references are visualized and how they affect the game's memory usage.

💡Interfaces

Interfaces in the video are used as a method to interact with objects without creating a hard reference to them. They define a contract of functions and properties that an object can implement, allowing for communication with objects that adhere to the interface without directly referencing them. This can help in reducing memory footprint and managing dependencies more effectively.

💡Components

Components in the video refer to modular parts of an object that can be added or removed to provide additional functionality. They are used to extend the capabilities of game objects without hardcoding additional features. The video suggests that components can be used as an alternative to hard references to manage memory and dependencies.

💡Spawning Actors

Spawning actors in the video means creating instances of game objects, such as characters or vehicles, during the game runtime. The method of spawning can be influenced by whether an asset is referenced hard or soft. Hard references allow for immediate spawning, while soft references may require additional steps to load the asset into memory before it can be spawned.

💡Asynchronous Loading

Asynchronous loading, as mentioned in the video, is a method of loading assets into memory that does not block the main game thread, allowing for smoother performance. It is particularly useful when dealing with soft references, as it allows assets to be loaded into memory on-demand without stalling the game.

Highlights

Introduction to the concept of hard and soft references in game development.

Explanation of how hard references affect the memory footprint of assets.

Demonstration of using the reference viewer in Unreal Engine to check dependencies.

Impact of hard references on loading assets into memory during runtime.

Example of adding a helicopter asset and its effect on memory usage.

How to identify and manage hard references to optimize memory usage.

Introduction to soft references as a way to reduce unnecessary memory load.

Practical example of creating a soft reference to a helicopter asset.

Comparison of memory footprint between hard and soft references.

Explanation of the difference between hard and soft references in terms of speed and memory usage.

Technique for using interfaces to avoid hard references and reduce memory footprint.

Example of implementing an interface to interact with a helicopter asset without hard referencing.

Discussion on the trade-offs between using hard versus soft references.

Strategies for managing references to prevent excessive memory consumption.

Conclusion and call to action for developers to continue learning and optimizing their game development practices.

Transcripts

play00:01

[Music]

play00:05

welcome to an episode of being a better

play00:08

Game Dev so in this episode we are going

play00:11

to be checking out things like hard

play00:12

references soft references we're going

play00:14

to be talking about what they are how

play00:16

they function we're going to be checking

play00:17

out how the memory footprint of our

play00:20

different assets are affected by these

play00:22

things we're going to be checking out

play00:24

how references hang together and how

play00:28

pointing at different objects cause a

play00:30

cascading effect if we have hard

play00:32

references and how we can make use of

play00:34

soft references to avoid this we're also

play00:36

going to be checking out some different

play00:37

things like interfaces and components

play00:39

talking about it a little bit and see

play00:41

how we can use that to offset a few of

play00:44

the disadvantages of these things as

play00:46

well so stick around and check it

play00:49

out welcome back so in this video we're

play00:53

going to be talking a bit about hard

play00:55

references and soft references what they

play00:57

mean what's good and bad about them H

play01:01

how they work and also

play01:04

some workarounds to to avoid the the

play01:09

worst offenders so um starting off in

play01:14

this is a third person template project

play01:16

uh so it's just a third person character

play01:18

that's running around uh when we start

play01:21

and I have done a few things in this

play01:24

project I have added a asset in this

play01:27

case I've added a helicopter from from

play01:30

the Vigilante asset set it's available

play01:32

for free on the marketplace if that's

play01:34

something that you want um I have added

play01:37

a little bit of code to our third person

play01:40

character not a whole lot we'll go

play01:41

through it once it's relevant we have

play01:43

added some code inside of our level also

play01:48

very small amounts and I'll go through

play01:50

that when it becomes relevant as well um

play01:54

but starting off what what does it mean

play01:57

to have hard and soft references well if

play02:00

you take a uh blueprint for example or

play02:03

any asset in Unreal Engine you can go

play02:05

and check the reference viewer the

play02:08

reference viewer gives you this or a

play02:10

very similar view uh what this means is

play02:15

uh this is the blueprint in this case

play02:16

that we opened up and all the things to

play02:19

the right over here are assets that uh

play02:24

are being used by this

play02:26

blueprint all the assets to the left are

play02:29

are things that make use of this uh

play02:33

character in this case so everything on

play02:36

the right is dependencies for the

play02:38

character and everything on the left is

play02:41

something that has a dependency of the

play02:43

character uh so uh how this works is

play02:48

each of these lines represent a a um a

play02:53

dependency in the form of some kind of

play02:57

reference in the case here we have white

play03:00

uh lines and these are hard references

play03:04

so a hard reference means that Unreal

play03:07

Engine when it loads in a blueprint

play03:10

third person character in this case it

play03:13

loads up all its hard reference

play03:16

dependencies and loads them into memory

play03:18

so that it can access them whenever

play03:21

they're needed in runtime um this will

play03:25

show up for example if you go to uh

play03:29

let's go to our content folder and we go

play03:31

and right click on it and we say size

play03:34

map our size map here in this case

play03:36

consists

play03:38

of 208 megabytes of memory taken and of

play03:43

these 208 megabytes you can see what the

play03:45

different aspects of this character uh

play03:49

the memory is being used for so we can

play03:51

see that our skeletal mesh is here and

play03:53

it it uses

play03:54

2.7 megabytes and it consists of these

play03:57

boxes that are consisting inside of it

play04:00

etc etc so we we have a few different

play04:04

boxes here that represent the different

play04:06

usages for our character in this case um

play04:11

now when we have a reference in our

play04:15

character so if we were to go to our

play04:17

character and let's say we create a new

play04:20

variable so

play04:23

remember in our size map we had 28

play04:28

megabytes if we have another uh variable

play04:32

here and we make sure to choose BP West

play04:36

which is the the helicopter in this case

play04:39

and I say I want to have an object

play04:40

reference or a class reference these are

play04:43

both hard references so if I click one

play04:45

of these and I compile and I save and I

play04:48

go back to our content

play04:50

browser and I check size map you can see

play04:53

now that it's going to be 392

play04:56

mbes so just by having that reference in

play05:00

our character it now says to on engine

play05:04

that this is something I have a hard

play05:06

reference to this is something I need to

play05:08

keep track of so you need to load this

play05:10

into memory as well when I get loaded

play05:12

into

play05:13

memory and if we go to our reference

play05:15

viewer you can see here that we have

play05:18

these assets over here that we're

play05:19

depending on or that we are yeah

play05:22

dependent on these are the ones that we

play05:23

load in and in the bottom here we have

play05:25

our context for default if we were to

play05:28

refresh this now you can see that below

play05:30

that context we get now our helicopter

play05:33

so now we have a hard reference to that

play05:35

other blueprint and this is in our third

play05:38

person character so what this means is

play05:42

when we open up this map or when this

play05:44

game mode gets launched H either of

play05:47

those say that they have a reference to

play05:49

this character which will then load in

play05:50

the character and all its dependencies

play05:53

which means all of these things and that

play05:55

in case in this case means that we load

play05:57

in this helicopter as well and if we

play05:59

double click into that we can see that

play06:01

it has a set of dependencies as well

play06:03

that it needs to make use of right and

play06:06

you can also set the search reference

play06:09

depth here to something higher so if we

play06:11

were to do three or something like that

play06:13

no apparently not this the dependency

play06:16

depth I

play06:18

guess it's taking a little bit

play06:23

um this might be a little bit bloated

play06:25

for us to actually uh get a good

play06:28

overview of but essentially here you can

play06:30

see how this tree sort of uh grows with

play06:34

each level so there are probably further

play06:37

dependencies here that are all loaded in

play06:39

once this blueprint character is loaded

play06:41

in uh so so it's easy to see I hope that

play06:46

if you have hard references to a lot of

play06:48

different objects H you will be loading

play06:50

in a lot of different things a lot of

play06:52

different assets and note that this is

play06:55

my third person character and my third

play06:58

person character

play07:00

is inside of this map but despite the

play07:05

helicopter not being here it will still

play07:07

be loaded into memory so it's completely

play07:10

unnecessary in this case

play07:12

right so we're using up a lot of memory

play07:15

for no reason in this case so we're

play07:17

going to be uh removing that helicopter

play07:20

for

play07:24

now like

play07:25

that now hopefully you have a basic

play07:29

understanding of of hard references and

play07:30

how it sort of works let's take a look a

play07:32

little bit at soft references so if we

play07:35

go into our third person character and

play07:37

we go in and create a variable and we

play07:40

call it

play07:42

helicopter inside of here we can choose

play07:45

to have the type

play07:47

actor and of these we have the two hard

play07:50

reference versions up here object and

play07:53

class we have to have two soft object

play07:55

references in the form of a soft object

play07:58

soft object reference and a soft class

play08:00

reference so if we wanted to spawn in a

play08:03

a another blueprint in the world another

play08:06

class we could take the soft class

play08:08

reference uh in our type we can have

play08:11

actor but then as a soft object

play08:15

reference type class we can choose to

play08:17

have for example our

play08:20

helicopter so this means that it will

play08:22

take the footprint of an

play08:25

actor but it can reference a West

play08:28

helicopter in this case

play08:30

so if we go and check our uh character

play08:34

uh let's see we go over here blueprints

play08:36

we can see that our size map is the same

play08:39

it's 208 still it hasn't been affected

play08:41

by this because it's just loading

play08:43

another actor and it only it already

play08:45

knows about actors because we are an

play08:48

actor uh using this reference now we

play08:50

could spawn it into the world but we

play08:52

can't spawn it in just straight up

play08:54

because if we do this and we say uh

play08:57

spawn actor from CLA

play09:00

it's going to be running a conversion

play09:03

from our soft reference to this uh but

play09:08

this being a soft reference means it's

play09:10

not loaded into the world so we have to

play09:13

manually tell it when to do so which

play09:15

means that when we press here for

play09:17

example on our press 2 key we can say

play09:21

asynchronous

play09:23

load um

play09:27

assets class asset

play09:31

like so this means that we will now tell

play09:34

it at this point here to load in this

play09:36

asset so it won't take up memory until

play09:38

we reach this point it will however be

play09:42

of the base type object class instead of

play09:45

an actor which is needed for spawning an

play09:47

actor so we can't just hook it up like

play09:49

so so we could either cast it to an

play09:53

actor and then hook it up over

play09:56

here uh but and of course we would have

play10:00

to do the okay this is not what it

play10:02

wanted I meant to do this cast

play10:05

actor like so

play10:08

no cast

play10:12

actor close there we

play10:15

go and if we hook it up like so it we

play10:18

would be able to uh spawn it into the

play10:20

world the asynchronous means it's going

play10:23

to be loading and be done at some point

play10:26

which means that we have two execution

play10:27

pins here we have one pin for when it's

play10:29

starting and when for one is completed

play10:32

so in this case I would want to hook up

play10:34

to the completed one to say that okay

play10:36

once we have loaded into memory then we

play10:38

want to spawn the actor so if we were to

play10:41

go to

play10:42

our map here and press the two key and

play10:45

then I eject from here I can see that

play10:47

the helicopter is over here so we focus

play10:49

on it and here we can see the helicopter

play10:52

so we're spawning it into the world now

play10:54

properly and everything is fine but our

play10:56

third person character is still going to

play10:58

have the the memory footprint of 208

play11:01

megabytes like when we started the

play11:04

reference viewer now is going to be a

play11:06

little bit different if we refresh the

play11:08

reference viewer we're going to be

play11:09

seeing here now that we have our

play11:11

helicopter here like before but we now

play11:12

have a pink purple kind of a line

play11:15

instead of a white so this means that we

play11:17

have a a soft reference to this object

play11:20

so it's not necessarily needed to be

play11:22

loaded in once this asset is loaded into

play11:26

memory okay uh you you could also

play11:29

instead of just casting this actor you

play11:31

could just hook it up like so and this

play11:33

would work as

play11:35

well uh because this conversion is

play11:37

similar to the cast essentially so if we

play11:40

do this eject go here and focus on it so

play11:43

you can see the helicopter here is being

play11:44

spawned okay all is good and fine so far

play11:48

I hope

play11:50

so with a soft reference like this we

play11:52

won't take up as much memory uh and we

play11:56

will have a different uh relationship

play11:58

when comes to the reference viewer in

play12:00

what kind of assets will be needed to

play12:02

load in but we have the detriment of we

play12:05

need to choose when to actually load an

play12:07

asset in when we feel it's going to be

play12:09

needed and of course this means that we

play12:11

might need a little bit of time to do

play12:12

this depending on what kind of asset we

play12:14

load in so that might be something that

play12:16

you want to consider as

play12:18

well um the the differences between a

play12:24

soft and hard reference when it comes to

play12:26

accessing them is that a hard reference

play12:29

is going to be faster uh because it

play12:32

already has loaded it into memory so

play12:34

it's available a soft reference if you

play12:36

make use of it needs to first check and

play12:38

see if it exists before it actually can

play12:40

access the the object that it's

play12:43

referring

play12:44

to uh but but of course you have the

play12:47

memory as a offset for for that benefit

play12:50

then so the the speed over the memory

play12:54

and how do you combat this kind of

play12:57

situation uh other than using soft

play12:59

references how do you avoid uh hard

play13:02

references like this well let's take a

play13:05

look at the code that I have prepared so

play13:08

in our level we

play13:10

have if we go and open up our level

play13:13

blueprint here's our level blueprint uh

play13:16

we we're getting the third person

play13:17

character we're calling two events on it

play13:19

event one and two these are the ones

play13:21

that we see up here and they take in an

play13:23

actor as an input in our map currently

play13:26

we do not have an actor referenced here

play13:30

but let's say that we had our helicopter

play13:32

in the world here or this could be some

play13:35

other asset of course as well so if we

play13:37

go to our third person map here we can

play13:39

say that we want to create a reference

play13:40

to the helicopter and we say that we

play13:42

want to send that as an input to our

play13:48

events

play13:49

um what's happening here now is that in

play13:52

our third person character we're getting

play13:53

these events sent to us when we press

play13:55

the key and we get an actor here and

play13:57

let's say we wanted to do something with

play13:59

the helicopter in the helicopter we have

play14:01

a little bit of code we have an event

play14:02

that says helicopter event and we have

play14:04

an interface called helicopter interface

play14:06

event when the event is called the

play14:09

helicopter event we print out that the

play14:10

helicopter event has been triggered when

play14:12

the interface gets called we call in

play14:14

this event and say the same thing

play14:16

essentially

play14:18

so if we were to go to our character now

play14:22

compile save and go here and check the

play14:25

memory

play14:26

map we can see that it's still at 208

play14:29

but the moment we say okay we want to

play14:31

make this a cost to BP

play14:36

West so that we are able to make use of

play14:39

the helicopter

play14:42

event helicopter event there we

play14:48

go so now if I were to go in here and

play14:51

play I press one we can see that the

play14:53

helicopter event is triggered is printed

play14:55

up in the the top left over

play14:57

there uh but now that we have had added

play15:00

this cast to our class that means that

play15:03

we have now created our hard reference

play15:05

so if we go to reference viewer we can

play15:07

see that it's back here with a white uh

play15:09

line and it's again going to be taking

play15:12

up memory for us for our character

play15:15

because we're forcing it to be loaded in

play15:16

now so this way causes us to create a

play15:20

hard reference and even if we didn't

play15:22

have this helicopter in the level just

play15:25

the existence of this cast would say

play15:27

that this blue print this third person

play15:30

character needs to have this helicopter

play15:32

loaded into memory to be able to

play15:33

function because we have this cost it's

play15:35

a hard

play15:37

reference if we remove this and instead

play15:40

say we want to call on the

play15:46

helicopter let's see here

play15:49

helicopter interface event so this

play15:54

one is calling on an actor saying we

play15:57

want to call the helicopter interface

play16:00

event and since it is an interface it

play16:03

will work if it has the interface if it

play16:04

does not have the interface it will do

play16:07

nothing uh the interface itself will

play16:10

again if we go in here and I press one

play16:11

you can see that the helicopter event is

play16:13

being triggered because we are calling

play16:16

the helicopter interface event which is

play16:18

calling the helicopter event which is

play16:20

calling the print string now if we go to

play16:22

our reference viewer refresh our

play16:24

character can see we have a soft

play16:26

reference to our helicopter which is of

play16:28

course from our helicopter over here if

play16:31

we were to remove this compile and

play16:34

save refresh our reference can see that

play16:37

we don't have a a a um dependency to

play16:42

anything except for our BPI here and

play16:45

that one is just being used by

play16:46

helicopter it's not actually a reference

play16:48

or a dependency for the helicopter so

play16:51

this this way we don't load in the

play16:53

helicopter at all we don't have a hard

play16:54

reference to it we don't have a soft

play16:56

reference to it we still able to uh

play16:59

access the code in it and if we check

play17:01

the memory we can see that our size map

play17:04

is 208 as well so an interface is one

play17:08

way to circumvent having hard references

play17:10

and avoid uh both the the hard reference

play17:15

um dependencies and also the memory

play17:17

footprint of your classes you could also

play17:20

do things with uh things like components

play17:23

and stuff and offload things that way uh

play17:25

I won't be showing that off in this

play17:27

tutorial however

play17:29

anyway uh that is

play17:34

hopefully understandable and it's the

play17:37

the sort of core concept of of hard and

play17:39

soft references um so the benefit of

play17:43

hard references again you're going to be

play17:45

having faster access time T because you

play17:47

always have the object available for you

play17:49

when you run um the payment for it is

play17:53

that you have to load everything into

play17:54

memory and that could be easily getting

play17:57

out of hand if you have a a lot of

play17:58

reference in because again if you have

play18:01

your reference viewer here you have

play18:04

let's do it like this we do a now let's

play18:07

do the cost we do a cost DP helicopter

play18:10

no not where helicopter there we go so

play18:15

in this case here we have the cost which

play18:16

means that we have a hard reference

play18:18

which means that it it is available here

play18:20

and if this helicopter in turn had a

play18:23

cost to let's say another helicopter

play18:26

then that helicopter would be loaded in

play18:27

and let's say that helicopter had I

play18:30

don't know a missile or something loaded

play18:32

as a direct reference the tree just

play18:35

expands and explodes if you don't keep

play18:37

track of how you're making use of your

play18:39

different references so that's why it's

play18:42

easy that the memory consumption can

play18:44

just get out of hand when when doing

play18:47

this so the soft references are of

play18:49

course a better choice when you're

play18:52

having certain objects that you don't

play18:54

need to have available at all times so

play18:56

it sort of depends on what kind of

play18:57

object that you're working with some

play18:59

things you will know that you always

play19:00

have reference uh a a need for and then

play19:04

having a direct reference a hard

play19:05

reference is is fine of course because

play19:08

you're going to be needing to access it

play19:09

at at all points or at any

play19:11

point so the soft references allows us

play19:15

to have a a smaller memory

play19:17

footprint uh it comes at the cost of

play19:19

being a little bit more finicky to work

play19:22

with since you need to make sure that

play19:23

you actually load it into memory before

play19:25

you spawn it into the world or interact

play19:27

with it

play19:28

anyway and such and uh you have some

play19:32

options of circumventing hard references

play19:34

as well using things like interfaces and

play19:37

components and such as well so that's

play19:41

going to be all for now keep on learning

play19:43

take

play19:44

care a big thank you to all of you who

play19:47

like comment subscribe and share my

play19:49

videos or through other means support

play19:51

this channel you are what makes this

play19:53

channel grow and become a resource for

play19:55

other people to learn from

Rate This

5.0 / 5 (0 votes)

相关标签
Game DevelopmentMemory ManagementUnreal EngineHard ReferencesSoft ReferencesAsset OptimizationProgramming Tutorial3D ModelingBlueprintsPerformance
您是否需要英文摘要?