Skip to content

Instantly share code, notes, and snippets.

@curious-username
Last active November 18, 2021 02:03
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/2754052dc88dcb592c73d19650243b92 to your computer and use it in GitHub Desktop.
Save curious-username/2754052dc88dcb592c73d19650243b92 to your computer and use it in GitHub Desktop.
camera shake when player takes damage
private CameraShake _playerShake;
void Start()
{
_playerShake = GameObject.Find("Camera").GetComponent<CameraShake>();
}
public void Damage()
{
switch (_isShieldActive)
{
case true:
_shieldLife--;
if (_shieldLife == 2)
{
_shieldDamage.color = Color.magenta;
}
else if(_shieldLife == 1)
{
_shieldDamage.color = Color.red;
}
else {
_isShieldActive = false;
_shield.SetActive(false);
_shieldDamage.color = Color.white;
_shieldLife = 3;
}
break;
case false:
_lives--;
_playerShake.ActivateShake();
_uiManager.UpdateLives(_lives);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment