Creating Functions

One of the advantages of Functions is that a Function created in one Blueprint can be called from another Blueprint. To create Functions, use the My Blueprint panel and click the + button in the Functions category. The following screenshot shows the My Blueprint panel with a Function named CalculateWaveBonus:

As with Macros, the attributes of the Function are displayed in the Details panel, where input and output parameters can be defined. The following screenshot shows the Details panel of the CalculateWaveBonus Function, with two input parameters and one output parameter:

When creating a Function, we can define whether it will be Pure. To do this, check the Pure attribute shown in the previous screenshot. A Pure Function has no execution pins; therefore, it can be used in expressions. Pure Functions should not modify the variables of its Blueprint, so they are mostly used as get-type Functions. The following screenshot shows the visual difference between a standard Function and Pure Function:

The following screenshot shows the contents of the CalculateWaveBonus Function. This Function calculates Bonus Points of a wave based on Wave Number and Time Left. The value found is returned via the Bonus Points output parameter:

The following screenshot is of the node that represents the CalculateWaveBonus Function. It can be added to the Event Graph panel from Context Menu by right-clicking Event Graph or by dragging the Function name from the My Blueprint panel and dropping it in Event Graph:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset