void OnTriggerStay2D(Collider2D col) { if (col.gameObject.tag == "Enemy") { Enemy_Slime enemy = col.gameObject.GetComponent <Enemy_Slime>(); if (isAttacking) { int mult = (attackType == AttackType.Strong) ? 2 : 1; enemy.Damage(strengh * mult); int dir = (isFacingRight) ? 1 : -1; col.attachedRigidbody.AddForce(new Vector2(dir * pushStrengh, 0)); isAttacking = false; } } }
void OnCollisionStay2D(Collision2D col) { if (col.gameObject.tag == "Enemy") { Enemy_Slime enemy = col.gameObject.GetComponent <Enemy_Slime>(); if (enemy.isAttacking) { camscript.Shake(); health -= enemy.strengh; int dir = (isFacingRight) ? 1 : -1; rigidbod.AddForce(new Vector2(dir * enemy.strengh * 100, 0)); if (health == 0) { Dying(); } } } }
public void SetEnemySlime(Enemy_Slime es) { this.es = es; }
private void Awake() { es = GameObject.FindObjectOfType <Enemy_Slime>(); }