sábado, 26 de março de 2016

BP Compendium: Cast To

Cast To


Convert the type of the reference variable to a new type specified. This is necessary in some situations to be able to access the variables and functions of a class or blueprint.

Input

  • Object: A reference to an object.

Output

  • Cast Failed: Execution pin that is used if the referenced object is not of the type used in the Cast.
  • As (new type): A reference using the new type specified in the Cast.


Example Usage

A new blueprint was created called "Machine". It is of the "Actor" type. This blueprint has a function called "Recharge Battery". A reference of the "Actor" type can be used to manipulate this new blueprint, but it would not have access to the function "Recharge Battery" because it can only access the variables and functions that were created in the  "Actor" type. To access the "Recharge Battery" function we need a reference of the "Machine" type. See the illustration below:



In another blueprint called "Recharger", there is an overlap event. If the actor who overlaps is of the "Machine" type, then it will be called the "Recharge Battery" function using the reference of the "Machine" type that was provided in the "Cast To".

Click to enlarge