Exemplo n.º 1
0
 public void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.CompareTag("Player") && isEnemy)
     {
         ShipSystem ship = collision.gameObject.GetComponent <ShipSystem>();
         ship.ShipDamage(bulletDamage);
         Destroy(gameObject);
     }
     else if (collision.gameObject.CompareTag("Enemy") && isPlayer)
     {
         EnemyAI enemyShip = collision.gameObject.GetComponent <EnemyAI>();
         enemyShip.DamageEnemy(bulletDamage);
         Destroy(gameObject);
     }
 }
Exemplo n.º 2
0
    private void Update()
    {
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));

        Debug.DrawRay(ray.origin, ray.direction * 5, Color.red);

        if (Input.GetButtonDown("Fire1"))
        {
            if (Physics.Raycast(ray, out hit, 5))
            {
                if (hit.collider.gameObject.tag == "Enemy")
                {
                    EnemyAI enemy = hit.collider.gameObject.GetComponent <EnemyAI>();
                    enemy.DamageEnemy(10);
                }
            }
            animator.SetBool("isShooting", true);

            StartCoroutine(ResetAnimator());
        }
    }