Зміст курсу
Unreal Engine FPS Game
Unreal Engine FPS Game
Create Enemy BP
In this chapter we will take a look at how to make a new blueprint for the enemies. Furthermore, we will add some functionalities so that once we shoot the enemy, it explodes!
To create a new blueprint, go to content and create a new folder by pressing the right click and choosing New Folder, and name it EnemyBlueprints
.
Open the folder and create a new blueprint class by pressing the right click and choosing Blueprint Class from the menu. Then choose Character under Common to create a blueprint of the class Character.
Give it the name BP_Enemy
and press enter. Open the BP_Enemy
and in the Components tab, click on Add.
Search for Cube and choose it to add a Cube to the blueprint. Give it the name SM_EnemyCube
. This represents our enemy. You can change the static mesh to something else too.
Press the add button again and type in Arrow, and then add the Arrow component.
Select the arrow component and in the details panel, search for Hidden in Game and uncheck the box. This will allow us to see where the enemy is looking. By default, the arrow shows the forward direction of this blueprint.
Select the Capsule Component and look for Capsule Radius set that to 88
.
Select the SM_Enemy
. Scroll down in the details panel and find Collision Present, click on the drop down and select Custom. Here we want to find Projectile, and set that to Overlap like below.
Then scroll down some more and under Events click on the button in front of On Component Begin Overlap this should take you to the Event Graph and create an On Begin Overlap event for you.
Drag out of the blue node Other Actor and type in cast to FirstPersonProjectile and choose the FirstPersonProjectile.
Connect the Begin Overlap to the cast node by dragging from its *execute node (the triangle) and attach it to the cast node that we just created.
Now drag out of the cast to node and type Spawn Emitter at Location and choose that function.
Click on the Emitter Template and choose P_Explosion
.
Right click beside the Spawn Emitter node that you just created and type in Get Actor Location and choose the node. Then hook that into the Location of the Spawn Emitter and set the scale properties to 2
like below.
Once you have done that, drag out of the execute pin of the spawner and look for Destroy Actor.
Compile and save. Go back to the FirstPersonMap and drag the blueprint that we just created into the scene. Now once you shoot the cube, it explodes!
Дякуємо за ваш відгук!