can anyone help me plz? i’ve been trying to fix this problem for the past hour (i’m still fresh to c#)
Basically i want to implement camera shake every time the enemy dies. I wrote the code for it in a public void alongside death effects and deletion of the gameobject. The weird thing is, when i kill the enemy through shooting, everything happens except the camera shake. i thought it was a code error but the weirder thing is that, when i kill the enemy through player-enemy collision (on contact death), the camera shake takes place. What’s even weirder is that, btw I’ve written the enemy one first, I have the same exact one but for when the player dies, and it works. i’ll write the code if anyone wants to check it
This one is for when the enemy dies
public void DamageEnemy(int damage)
{
stats.currentHealth -= damage;
if (stats.currentHealth <= 0)
{
GameMaster.KillEnemy(this);
Debug.Log("Enemy Dead");
}
if (statusIndicator != null)
{
statusIndicator.SetHealth(stats.currentHealth, stats.maxHealth);
}
}
This one is to do whatever I want when the enemy dies (everything works except the camera shake)
public static void KillEnemy(Enemy enemy)
{
gm._KillEnemy(enemy);
}
public void _KillEnemy(Enemy _enemy)
{
Destroy(_enemy.gameObject);
GameObject _clone = Instantiate(_enemy.deathParticles.gameObject, _enemy.transform.position, Quaternion.identity) as GameObject;
Destroy(_clone, 5f);
cameraShake.Shake(_enemy.shakeAmt, _enemy.shakeLength);
}
}