UE5

Five Skills You Must Avoid in Unreal Blueprints - Cast To

게임 개발 2024. 5. 31. 18:28

 

Five programming skills, 
why are they so bad in BP

Do you know 5 bad programming in bp?

They are Cast To, Event Tick, Bind Event, Delay and Get All Actors Of Class.

  1. Cast To
  2. Event Tick
  3. Delay
  4. Get All Actors Of Class
  5. Bind Event

1. Why you should NEVER use "Cast To" Node in BP!

 

If you add Sphere Collision Component in an actor class.

What this essentially do is that when your player touches the sphere, something will happen.

And if you want to use information from our player such as health variable so we can damage our player,

for example, such as shown in the picture below.

We will drag pin from here.

 

But, here's the thing nobody says how bad this is for your game and you should actually never use it.

 

NEVER USE CASTING NODE!

 

Now let's see why is that?

However over the node and read the note.

It says this will cause the BP to always be loaded, which can be expensive.

Let me show you what this means.

 

 

 

Just focus on the top here on this one, because that's the total memory we need to see.

So this actor takes memory 110MB, which is a lot.

And please remember there is nothing in this sector.

Just the sphere and sphere collision.

 

This is because we are casting to our third person character and everytrhing that character has,

such as material, textures, bp.

All of this will be loaded every time when casting.

 

So this is all because of the casting of the third person character simply by calling this node.

So even though there is nothing in our actor, we have just created a sphere collision in a static mesh.

Our actor uses all the memory from the third person character just because of calling this node.

 

 

Therefore, a possible solution could be written as follows.

 

 

If you share this content, please provide credit.