Ranged Enemies
Last updated
Last updated
Ranged Enemies is a feature introduced in version 1.1.0. It allows you to quickly and easily add enemies that shoot projectiles in different manners.
Adding an enemy of this type is identical to the Simple Enemies. Visit Add a Simple Enemy to learn more.
Ranged Enemies share all the base settings with Simple Enemies. However, there are some notable differences. To see how this setup works in practice, let's take a look at the example prefab.
Navigate to and open it.
Prefab structure is the same as for Simple Enemies, apart from the Behavior Script. As usually, it is attached to the parent object of this prefab.
Take a look at the Ranged Enemy Behavior script. It should look like this:
Adjust the settings according to your desires.
If you want to turn a simple enemy into ranged one, you can do it easily by swapping Behavior script to a ranged one. Make sure to assign everything properly.
Projectile Prefab field has to link to a proper projectile for this to work.
Let's take a look at the example Projectile prefab.
Projectile prefab has a parent object, and a particle as a child. You can use any particle that fits your vision here.
In the parent object you will see 2 important components: 2D Collider and a Simple Enemy Projectile Behavior Script.
Make sure that your projectile has these components attached
Also make sure that Layer is correctly set to Enemy Projectile.
The Trail field in Simple Enemy Projectile Behavior script is optional - if your particle doesn't use trails you can leave it empty.
Navigate to and open it.