New Enemy Type

Kinga Osińska
2 min readMay 17, 2021

--

Today, we will crate a new enemy type that will fire and damage the player. We will create unique projectile and unique movement.

Our new enemy will be moving from left to right. We need to add to our new enemy: Collider2D, Rigidbody2D (gravity = 0), Enemy script, Animator (controller = Enemy), and Audio Source (explosion_sound). Make a prefab.

In the SpawnManager script, change _enemyPrefab to an array, and add a new enemy to the Inspector

In the SpawnEnemies() method we need to spawn random enemy. The two enemies that we spawn, have different spawning position and rotation. We will use if statement to check which enemy we will spawn.

In the Enemy script we add a new variable to check which enemy it is.

In the CalculateMovement() script we will check the bool variable and move our enemy to spawn point when it is outside of the screen.

--

--