Which is better? 'Is a child of' or 'CastTo'?

I’ve been looking at many blueprinting tutorials for building my inventory system, and I’ve seen both of these methods used to check if a blueprint is a child of another.

I have no idea which one of these methods are the better practice. In either case, I only need to check if the class of the blueprint in question is a child of the other.

Here are some pictures to clarify.

or is this better

I’m especially interested in which one of these might be ‘better practice’ in terms of performance, or otherwise. It just feels a bit weird to me to use the CastTo if i’m not doing anything with it other than checking if it succeeded.

The main reason you cast to anything is because you can’t get access to functions or variables of this class other way.

That’s exactly what i would assume, but I still see it being used frequently in this manner in tutorials or otherwise. Even on some peoples questions in the answerhub, it has been suggested. I also see the other way suggested, so I’m really interested in which one is better and in what cases.

Both functions have their use!

Casting is used to cast an instance of A to B and vica versa!

Preferably used if the object is derived from same type and you want to get that specific type, it can be child or parent.

So lets say you have two classes.

Class A

Class B derived from A.

You have an instance of B then you can cast it back to A. and get access to it, but you can also cast it back to B again and get access to B, since the instance is still the same instance as it was before nothing has changed.


While the is Child of only tells if your class is derived from a parent class. With this you can simply check:

Is B child of A?


About performance i am not sure that such a small thing should matter at all, but probably checking the class type is better for what you want to achieve, so use IsChildOf to check if A is child of B. And use casting if you want to get cast something and do something with the result. But casting can be used for the same purpose if you feel like.

I am very aware of the actual use of each, but i guess that’s useful to have here for others with the same question.

The last portion of your answer is more what i’m looking for, although no specific answer was given. I want to know in this specific case, which one of these methods are better, because they have to compile down to different code right?

1 Like