quarta-feira, 21 de abril de 2021

EnemyCannon: Implementing BlueprintNativeEvent

In this article, we will implement the Blueprint version of BlueprintNativeEvent DestroyCannon().

Open the BP_EnemyCannon Blueprint that we created in the previous article.

On the My Blueprint tab, click the Override button next to Functions and select Destroy Cannon. The DestroyCannon() function will be represented as an Event in Blueprint because it does not return a value.


Right-click on the Event Graph next to the Destroy Cannon Event and add the Spawn Actor from Class action. In the Class parameter, select BlueprintEffectExplosion. Right-click on the Spawn Transform parameter and select the Split Struct Pin option so that we can enter Location and Scale separately.


Set the value 5 to X, Y, and Z in SpawnActor's Spawn Transform Scale parameter. Add the GetActorLocation and DestroyActor Actions to the Event Graph and connect the nodes as shown in the image below.


These actions will create an explosion at the cannon location and remove the cannon from the game.

When the DestroyCannon() function is called in C++, it will be this Blueprint version that will be executed.

Compile and save the Blueprint.


Table of Contents C++