Created
December 26, 2021 04:06
-
-
Save curious-username/3825ff0b798ea9fc79f3c842c02cd2d9 to your computer and use it in GitHub Desktop.
enemy movement meat and potatoes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Movement() | |
{ | |
transform.Translate(_direction * Time.deltaTime * _speed * _speedMultiplyer); | |
if (_isPlayerLaserSpawned == true) | |
{ | |
_playerLaser = FindObjectOfType<Laser>(); | |
if (_playerLaser != null) | |
{ | |
var laserPosition = _playerLaser.transform.position - transform.position; | |
if (laserPosition.y > -3.0f) | |
{ | |
_speedMultiplyer = 3.0f; | |
if (_fireLaser == true) | |
{ | |
Instantiate(_enemyLaser, transform.position, Quaternion.identity); | |
_fireLaser = false; | |
} | |
_direction = Vector3.right; | |
} | |
if (laserPosition.x > 1.5f || laserPosition.x < -1.5f) | |
{ | |
_speedMultiplyer = 1.0f; | |
_direction = Vector3.down; | |
} | |
_isPlayerLaserSpawned = false; | |
} | |
} | |
if(transform.position.y <= -6f) | |
{ | |
Destroy(gameObject); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment