Space Patrol Attack
In our game, our Space Patrol will approach the player's spaceship and attack it. Last week, I finished the Space Patrol pathfinding toward the player spaceship. This week, I finished the Space Patrol attack and was able to interact with the spaceship health system that Anuraj implemented.
In the part of the Space Patrol attack, I designed the way to set one or more arrows on the Space Patrol mesh to point to the player's spaceship as the direction of the missile generation. When the spaceship enters the attack range, it will start a continuous missile launch toward the player's spaceship. On top of that, I also added a bit of VFX for the missile explosion.
Implement Explanation
1. First, we need to create an Actor for the missile. The most important part is that this Actor needs to contain Projectile Movement (so that it will fly continuously) and Collision Box (to cause damage when detecting spaceship collision). Secondly, we need to adjust the initial speed and maximum speed of the Projectile of the Mesh and turn off gravity. Finally, we need to add an appropriate velocity to the missile in the correct direction (I added the x-axis direction).
2. The second step is to add an attack direction arrow to our Space Patrol and make it always point to our player spaceship, and then generate the missile we just made in this direction. (Inside the Space Patrol Character implement a customized event)
3. In The third step, because we want Space Patrol to perceive the attack range before launching the missile, so we use the AI Perception we made before to generate a boolean value whether it is within the range or not. And finally, in the Event Tick, check the boolean value and decide whether to launch the missile.
4. Finally, let the launched missiles cause damage to our player's spaceship. In the Actor of our missile, we create a custom event of Damage Player to interact with Anuraj's spaceship HP through the blueprint of Apply Damage. It causes damage at the moment of collision, and after an explosion effect is issued, it destroys the missile.
Demo
Multiple Space Patrol Demo
Comments
Post a Comment