void SpawnDrone() { Vector3 location = locationNumber * new Vector3(1000, 1000, 0); PlayerInput droneInput = Instantiate(Projectile, location, Quaternion.identity).GetComponent <PlayerInput>(); droneInput.SwitchCurrentControlScheme(shipInput.currentControlScheme); drone = droneInput.GetComponent <ShipXDrone>(); drone.SetShooter(this); droneRb = drone.GetComponent <Rigidbody2D>(); droneCollider = drone.GetComponent <Collider2D>(); droneCollider.enabled = false; drone.tag = tag; }
public override void Shoot() { foreach (Transform shotLocation in ShotLocations) { float forceMultiplier = Random.Range(chargedData.MinForce, chargedData.MaxForce); float rotation = Random.Range(-chargedData.RotationVariation, chargedData.RotationVariation); drone.transform.position = shotLocation.position; drone.transform.rotation = shotLocation.rotation; drone.StartLife(); droneCollider.enabled = true; droneRb.rotation += rotation; droneRb.AddRelativeForce(Vector2.up * chargedData.ShotForce * forceMultiplier); drone.GetComponent <CannonShooter>().ResetState(); shotLocation.gameObject.GetComponent <AudioSource>().Play(); shotLocation.tag = tag; StartCoroutine(ActivateEngine(drone.gameObject)); if (Data.LimitedAmmo) { ExpendAmmo(); } TriggerShotEvent(); } }