Skip to content

Instantly share code, notes, and snippets.

@curious-username
Created December 18, 2021 23:36
Show Gist options
  • Save curious-username/b6d1d307ad18d38aa77d06f31c76eecc to your computer and use it in GitHub Desktop.
Save curious-username/b6d1d307ad18d38aa77d06f31c76eecc to your computer and use it in GitHub Desktop.
enemymovement
void Update()
{
EnemyMovement();
}
void EnemyMovement()
{
transform.Translate(Vector3.down * _speed * Time.deltaTime);
transform.Translate(_direction * _speed * Time.deltaTime);
if (transform.position.x >= 3)
{
_direction = Vector3.left;
}
else if (transform.position.x <= -3)
{
_direction = Vector3.right;
}
if (transform.position.y <= -6)
{
Destroy(gameObject);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment