void OnTriggerEnter2D(Collider2D other) { ShotScrpit shot = other.gameObject.GetComponent <ShotScrpit>(); if (shot != null) { if (shot.isEnimyShot != isEnemy) { Damage(shot.danage); Destroy(shot.gameObject); } } }
public void Attact(bool isEnemy, Vector2 direction) { if (CanAttack) { shootCooldown = shootingRate; var shotTransform = Instantiate(shotPrefab); shotTransform.position = transform.position; ShotScrpit shot = shotTransform.gameObject.GetComponent <ShotScrpit>(); if (shot != null) { shot.isEnimyShot = isEnemy; } MoveScript move = shotTransform.gameObject.GetComponent <MoveScript>(); if (move != null) { move.direction = direction; } } }