private void AttackUpdate() { if (shoot) { GameObject obj = Instantiate(bulletPrefab, transform.position, Quaternion.identity, transform); Enemy2Bullet bullet = obj.GetComponent <Enemy2Bullet>(); directionBullet = targetTransform.position - transform.position; directionBullet = directionBullet.normalized; bullet.SetDirection(directionBullet); shoot = false; } //logica de disparar el proyectil, dar velocidad, direccion, daƱo }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Bullet")) { Enemy2Bullet go = collision.gameObject.GetComponent <Enemy2Bullet>(); //go.InvertDirection();// cuando colisione con el player tendira que dar media vuelta. if (mirrorUp) { go.InvertDirection(); //Debug.Log("Revota"); } else { energy.Damage(); go.Destroied(); //Debug.Log("No rebota"); } } }