void Shoot() { Vector2 firePointPosition = new Vector2(Alienfirepoint.position.x, Alienfirepoint.position.y); Vector2 targetPosition = new Vector2(target.transform.position.x, target.transform.position.y); RaycastHit2D hit = Physics2D.Raycast(firePointPosition, targetPosition - firePointPosition, 100, whatToHit); //Debug.DrawLine(firePointPosition, (targetPosition - firePointPosition) * 100, Color.cyan); if (hit.collider != null) { //Debug.DrawLine(firePointPosition, hit.point, Color.red); } GameObject bulletClone = ObjectPoolingScript.poolingScript.GetPooledObject("alienBulletList", alienBullet.gameObject); //Transform bulletClone = (Transform) Instantiate(alienBullet, Alienfirepoint.position, Alienfirepoint.rotation); bulletClone.transform.position = Alienfirepoint.position; bulletClone.transform.rotation = Alienfirepoint.rotation; bulletClone.SetActive(true); gameObject.GetComponent <AudioSource>().Play(); BulletScript bs = bulletClone.GetComponent <BulletScript>(); bs.DamageToDo(Damage); }