Day 42 — Improvments: new enemy

private bool _isBackwardEnemy = false;
[SerializeField]
private GameObject _backwardLaser;
public void BackwardEnemy()
{
_isBackwardEnemy = true;
}
private void FireBackwardLaser()
{
if (_enemyCanFire == true)
{
if (transform.position.y < _player.transform.position.y && Time.time > _nextFire)
{
_nextFire = Time.time + _fireRate;
GameObject backwardEnemy1 = Instantiate(_backwardLaser, transform.position + new Vector3(0, 0.5f, 0), Quaternion.Euler(0, 0, 30));
GameObject backwardEnemy2 = Instantiate(_backwardLaser, transform.position + new Vector3(0, 0.5f, 0), Quaternion.Euler(0, 0, 0));
GameObject backwardEnemy3 = Instantiate(_backwardLaser, transform.position + new Vector3(0, 0.5f, 0), Quaternion.Euler(0, 0, 330));
}
}
else
{
return;
}
}
private int _backwardEnemyCount;
[SerializeField]
private GameObject _backwardEnemy;
if (_backwardEnemyCount < 2)
{
Vector3 backwardPosition = new Vector3(Random.Range(-10.7f, 10.7f), 6.2f, 0);
GameObject backwardEnemy = Instantiate(_backwardEnemy, backwardPosition, Quaternion.identity);
Enemy _backwardEnemyScript = backwardEnemy.GetComponent<Enemy>();
backwardEnemy.transform.parent = _enemyContainer.transform;
_backwardEnemyScript.BackwardEnemy();
_backwardEnemyCount += 1;
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store