EnemyCannon: Extending into Blueprint

In this article, we are going to create the child Blueprint of EnemyCannon.

In the Content Browser, access the TutoPart3 folder that is inside the C++ Classes folder. Right-click on the EnemyCannon class and choose the option Create Blueprint class based on EnemyCannon:

On the next screen, write BP_EnemyCannon 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.

Open the Blueprint BP_EnemyCannon and see in the Components tab the components that we defined in the C++ class.

Select the StaticMesh component. On the Details tab, select SM_MatPreviewMesh_02 for StaticMesh and M_Metal_Burnished_Steel for Material Element 0.

Select the ProjectileSpawnLocation component. In the Details tab, in Location set 150 to X and 200 to Z.

We need to define the Projectile Class that will be used by EnemyCannon. To do this, click on the Class Defaults button. In the Details tab, Cannon category, select the BP_EnemyProjectile in the Projectile Class variable. The values of the FireRate and MaxHits variables can also be modified in Class Defaults.

The variables shown in the image above can also be modified in the instances of EnemyCannon that are in the level, thus allowing to have Enemy Cannons in the level with different types of projectiles, firing times, and maximum number of hits.

See in the Viewport tab the appearance of BP_EnemyCannon. The red arrow is invisible in the game.

Compile and save the Blueprint.

In the next article, we will implement the BlueprintNativeEvent DestroyCannon() in Blueprint.

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed