void OnTriggerEnter2D(Collider2D otherCollider) { ShotScripts shot = otherCollider.gameObject.GetComponent <ShotScripts>(); if (shot != null) { if (shot.isEnemyShot != isEnemy) { Damage(shot.damage); Destroy(shot.gameObject); } } }
public void Attack(bool isEnemy) { if (CanAttack) { _shotCooldown = _shotingRate; var shotTransform = Instantiate(_shotPrefab) as Transform; shotTransform.position = transform.position; ShotScripts shot = shotTransform.gameObject.GetComponent <ShotScripts>(); if (shot != null) { shot.isEnemyShot = isEnemy; } MoveScripts move = shotTransform.gameObject.GetComponent <MoveScripts>(); if (move != null) { move.direction = this.transform.right; } } }