Pages

terça-feira, 16 de março de 2021

PlayerProjectile: Creating more child Blueprints

We are going to create two more types of projectiles that can be used by the player. They will also be implemented as child Blueprints of the PlayerProjectile C++ class.

We will make a copy of the Blueprint of the first type of projectile to take advantage of the configuration made in it.

In the Content Browser, access the FirstPersonBP/Blueprints folder and right-click on the Blueprint BP_PlayerProjectile1. Select the Duplicate option as shown in the image below and write the name BP_PlayerProjectile2 for the new Blueprint.


Click on the StaticMesh component on the Components tab. The StaticMesh properties will be displayed on the Details tab. Let's change the shape of the projectile. Select Shape_Pipe for Static Mesh and M_Metal_Copper for Material. In Rotation put 90.0 in Z and change the Scale to 0.5 in X, Y and Z.

Click on the ProjectileMovement component on the Components tab. In the Details tab, change the values for Initial Speed and Max Speed to 6000. This will double the speed of this projectile.


These are the only changes in BP_PlayerProjectile2. It will have the same Event Hit as BP_PlayerProjectile1. Compile and save the Blueprint.

Make another copy of BP_PlayerProjectile1 using the Duplicate option and write the name BP_PlayerProjectile3 for the new Blueprint. This projectile will simulate a grenade. It will have greater weight, so the player will need to shoot upwards, and it will explode when it collides with something.

In the properties of the StaticMesh change the Material to M_Tech_Hex_Tile_Pulse and keep the same Static Mesh and Scale as in the BP_PlayerProjectile1.


In the ProjectileMovement properties, change the Projectile Gravity Scale to 3.0.


In the Blueprint Event Graph, modify the Event Hit to have the actions shown in the image below. In the SpawnActor action, select the Blueprint Effect Explosion in the Class parameter. Right-click the Spawn Transform parameter and select the Split Struct Pin option. Change the Spawn Transform Scale to 5.0 on X, Y and Z.


Compile and save the Blueprint. We have completed the implementation of the PlayerProjectile and its child Blueprints. In the next article, we will start to implement the PlayerCharacter that will use the PlayerProjectile.


Table of Contents C++