Course Content
Unreal Engine FPS Game
Unreal Engine FPS Game
Enemy Projectile BP & Fire Projectile
In this chapter we make a projectile that the enemies can shoot at us!
To do that, make a blueprint of the class Actor.
Then, add two components, one a sphere collision, and the other a sphere (mesh). Adjust their sizes so that they are nice and small.
Then add a Projectile Movement component and set the first property in the Velocity to 1000
. Also, in the details panel, search for Projectile Gravity Scale and set that to zero
.
Select the sphere collision that you created and in the details panel click on the plus button in front of On Component Begin Overlap. Drag out of Other Actor and search for cast to BP_FirstPersonCharacter
. Then drag out of the blue output pin As BP First Person Character and call the Take Damage function that we created in the previous section. Drag out of As BP First Person Character again and Get Player Health. Create a Print String Node and connect the execute pin of our Take Damage to it, and print out the Player Health variable.
Now let’s go to the BP_EnemyChar
or whatever you named the Enemy blueprint. Create a delay node with a duration of 2
seconds. Then connect Simple Move to Actor and Set Actor Rotation to it.
Drag out of the Completed pin and search for Spawn Actor of Class and in the Class, choose BP_EnemyProjectile
. Right click on the Spawn Transform and select Split Struct Pin.
Right click and search for a node called Get Actor Transform. Right click on the output of it and choose Split Struct Pin.
Connect the location to the spawn actor’s location and the rotation as well. Leave scale as is. And that is it!
Thanks for your feedback!