Last active
November 18, 2021 02:03
-
-
Save curious-username/2754052dc88dcb592c73d19650243b92 to your computer and use it in GitHub Desktop.
camera shake when player takes damage
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
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