public Rocket(GameObject missileObject, uint nrOfMissiles, float speed, float turningSpeed, float maxDist, Position position, AntiPosition antiPosition, Camera camera, AbilitySelector selector, float timeout, float explosionForce) { // Create containers this.missilePool = new Queue <GameObject>(); this.activePool = new HashSet <GameObject>(); // Internal state this.camera = camera; this.selector = selector; // Fill the item pool for (uint i = 0; i < nrOfMissiles; ++i) { GameObject rocket = Instantiate(missileObject, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity); rocket.SetActive(false); Missile missile = rocket.GetComponent <Missile>(); missile.speed = speed; missile.turningSpeed = turningSpeed; missile.onDestroy = this.Destroy; missile.maxDistance = maxDist; missile.position = position; missile.timeout = timeout; missile.explosionForce = explosionForce; TrailShifter ts = rocket.GetComponentInChildren <TrailShifter>(); ts.SetSimulationSpace(antiPosition); missilePool.Enqueue(rocket); } }
public void SetSimulationSpace(AntiPosition p) { ParticleSystem ps = gameObject.GetComponent <ParticleSystem>(); var main = ps.main; main.simulationSpace = ParticleSystemSimulationSpace.Custom; main.customSimulationSpace = p.transform; }