sexta-feira, 12 de março de 2021

PlayerProjectile: Extending the C++ class in Blueprint

In this article, we are going to create the first child Blueprint based on the PlayerProjectile C++  class.

In the Content Browser, access the TutoPart3 folder that is inside the C++ Classes folder. Right-click on the PlayerProjectile class and choose the option Create Blueprint class based on PlayerProjectile, as shown in the image below. 

On the next screen, write BP_PlayerProjectile1 in the Name field. In the Path field, choose the Blueprints folder that is inside the FirstPersonBP folder and click the Create Blueprint Class button.

Double-click on the new Blueprint to open the Blueprint editor. See in the Components tab that the components that we defined in the C++ class were inherited by the Blueprint. Select the StaticMesh component to define the Asset.

The Details tab shows the properties of the selected StaticMesh component. Select the FirstPersonProjectileMesh Asset for the StaticMesh. Change the Scale to 0.1 in X, Y and Z.


In the Blueprint Event Graph, add the Event Hit and the DestroyActor action as shown in the image below. The instance of this Blueprint will be removed from the game when it collides with something.


Compile and save the Blueprint.


Table of Contents C++