Casting in Blueprints
There is a node named Cast To that tries to convert reference variable types to new specified types. To understand casting, it is necessary to remember the concept of inheritance between classes, which we covered in Chapter 3, Actors and the Gameplay Framework.
The following diagram represents a Blueprint called BP_GameModeWithScore
. Game Mode Base is the parent class of this Blueprint. Based on the inheritance concept, we can use a variable of the Game Mode Base object reference type to reference an instance of BP_GameModeWithScore
. However, this variable is unable to access the variables and functions of a subclass like those defined in the BP_GameModeWithScore
Blueprint, because a Game Mode Base reference only knows the variables and functions that are defined in the Game Mode Base class:
Therefore, if we have a Game Mode Base object reference, we can try to cast...