public void TakeDamage(float damage) { CinemachineShake.Instance.ShakeCamera(3f, 0.2f); health -= (int)damage; if (health <= 0) { RandomDrop.SpawnRandomDrop(transform.position, Quaternion.identity); Destroy(this.gameObject, 0.1f); } rb.AddForce(hitForce, ForceMode2D.Impulse); Debug.Log(health); }
public void TakeDamage(float damage, bool hitFromRight) { PlayDamageEffect(); health -= (int)damage; hitForce.x *= hitFromRight ? -1 : 1; rb.drag = drag; rb.AddForce(hitForce, ForceMode2D.Impulse); if (health <= 0) { RandomDrop.SpawnRandomDrop(transform.position, Quaternion.identity); Destroy(this.gameObject, 0.1f); } Debug.Log(health); }
public void TakeDamage(float damage, bool hitFromRight) { PlayDamageEffect(); damagedState.HitSide(hitFromRight); damagedState.SetHitForce(hitForce.x, hitForce.y); StateMachine.ChangeState(damagedState); currentHealth -= (int)damage; CinemachineShake.Instance.ShakeCamera(3f, 0.2f); if (currentHealth <= 0) { if (enemyDelegate != null) { enemyDelegate(this); } RandomDrop.SpawnRandomDrop(AliveGO.transform.position, Quaternion.identity); Destroy(this.gameObject, 0.1f); } Debug.Log(EnemyName + " " + currentHealth); // Debug.Log(EnemyDelegateCount); }