Skip to content

Instantly share code, notes, and snippets.

@curious-username
Last active December 31, 2021 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curious-username/caa3e1f777fcbc4c1e1a918b6c3e8fbb to your computer and use it in GitHub Desktop.
Save curious-username/caa3e1f777fcbc4c1e1a918b6c3e8fbb to your computer and use it in GitHub Desktop.
private bool _fireLaser = true;
void Update()
{
DestroyPowerup();
}
private void DestroyPowerup()
{
GameObject powerupObj = GameObject.FindGameObjectWithTag("Powerup");
if (powerupObj != null)
{
var powerupPosition = powerupObj.transform.position - transform.position;
if (powerupPosition.x < 1.0)
{
if (_fireLaser)
{
Instantiate(_EnemyLaserPrefab, transform.position, Quaternion.identity);
_fireLaser = false;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment