// Update is called once per frame void Update() { float score = gameManager.Score; if (!gameManager.Started) { score = 0; } ParticleSystem.VelocityOverLifetimeModule velocity = rainParticle.velocityOverLifetime; velocity.xMultiplier = rainSpeedMultiplier * score; float targetVelocity = score * waveSpeedMultiplier + waveStartSpeed; if (targetVelocity > waveSystem.Speed) { waveSystem.Speed += waveLerpSpeed; } else { waveSystem.Speed -= waveLerpSpeed; } waterParticle.startSpeed = score * waterSpeedMultiplier + waterStartSpeed; waterParticle.emissionRate = score * waterRateMultiplier + waterStartRate; waveSystem.WaveHeight = waveStartHeight + gameManager.CurrentDist * waveHeightMultiplier; }
void DestroyHeal() { if (!startLine) { destroyed = true; //turn off collider healCollider.enabled = false; ParticleSystem.MainModule newMain = particles.main; newMain.gravityModifier = blockFallSpeed; //add velocity over time ParticleSystem.VelocityOverLifetimeModule newVel = particles.velocityOverLifetime; newVel.enabled = true; //turn on collision ParticleSystem.CollisionModule newCol = particles.collision; newCol.enabled = true; //destroy object after a couple seconds Destroy(gameObject, blocksLeftTime); } }
// Update is called once per frame void Update() { if (_isPlaying) { _currentTime += Time.deltaTime; Vector3 vec = ps.transform.eulerAngles; vec.x = -90; ps.transform.eulerAngles = vec; ParticleSystem.MainModule main = ps.main; main.startSpeed = 30 + 15 * _currentTime / _maxTime; ParticleSystem.VelocityOverLifetimeModule velocity = ps.velocityOverLifetime; ParticleSystem.MinMaxCurve curve = new ParticleSystem.MinMaxCurve(-30 * _currentTime / _maxTime, 30 * _currentTime / _maxTime); velocity.x = curve; velocity.y = curve; velocity.z = curve; ParticleSystem.ShapeModule shape = ps.shape; shape.radius = _maxRadius * _currentTime / _maxTime; ParticleSystem.EmissionModule emission = ps.emission; emission.rateOverTime = _maxRadius * 2000 * _currentTime / _maxTime; if (_currentTime > _maxTime) { _currentTime = 0; _isPlaying = false; } } }
// Use this for initialization void Start() { fuelemit = GetComponent <ParticleSystem>(); fuelemit.Stop(); fuelemit.Clear(); velocityModule = fuelemit.velocityOverLifetime; }
private IEnumerator windZoneStart() { sectors = GameObject.FindGameObjectsWithTag("Sectors"); //finds and defines the 8 sectors chosenWindZone = sectors[Random.Range(0, 7)]; // randomly chooses a sector ParticleSystem ps = chosenWindZone.GetComponentInChildren <ParticleSystem>(); ParticleSystem.MainModule psmain = chosenWindZone.GetComponentInChildren <ParticleSystem>().main; ParticleSystem.VelocityOverLifetimeModule psvelmod = chosenWindZone.GetComponentInChildren <ParticleSystem>().velocityOverLifetime; //set the particle system variables psvelmod.orbitalY = -10.0f; ps.Play(); // start playing the emitter WindStartUpSound.PlayOneShot(WindStartUpSound.clip); WindStrength = Random.Range(0.2f, 1.2f); psmain.simulationSpeed = WindStrength; // play the emitter at a certain speed yield return(new WaitForSeconds(3)); psvelmod.orbitalY = 0.0f; Invoke("addStick", Random.Range(0, 4)); //throw in a stick between 1 to 3 seconds later Invoke("addStick", Random.Range(0, 4)); yield return(new WaitForSeconds(2)); //3 second pause ps.Stop(); // stop the emission Invoke("windZoneInit", Random.Range(2, 5)); // loop this function randomly between 2 to 7 seconds later }
protected override object WriteToImpl(object obj) { obj = base.WriteToImpl(obj); ParticleSystem.VelocityOverLifetimeModule uo = (ParticleSystem.VelocityOverLifetimeModule)obj; uo.enabled = enabled; uo.x = x; uo.y = y; uo.z = z; uo.xMultiplier = xMultiplier; uo.yMultiplier = yMultiplier; uo.zMultiplier = zMultiplier; uo.orbitalX = orbitalX; uo.orbitalY = orbitalY; uo.orbitalZ = orbitalZ; uo.orbitalXMultiplier = orbitalXMultiplier; uo.orbitalYMultiplier = orbitalYMultiplier; uo.orbitalZMultiplier = orbitalZMultiplier; uo.orbitalOffsetX = orbitalOffsetX; uo.orbitalOffsetY = orbitalOffsetY; uo.orbitalOffsetZ = orbitalOffsetZ; uo.orbitalOffsetXMultiplier = orbitalOffsetXMultiplier; uo.orbitalOffsetYMultiplier = orbitalOffsetYMultiplier; uo.orbitalOffsetZMultiplier = orbitalOffsetZMultiplier; uo.radial = radial; uo.radialMultiplier = radialMultiplier; uo.speedModifier = speedModifier; uo.speedModifierMultiplier = speedModifierMultiplier; uo.space = space; return(uo); }
IEnumerator MoveOverSeconds(GameObject objectToMove, Vector3 end, float seconds) // Move the bike to the position that will be selected based on answer { float elapsedTime = 0; Vector3 startingPos = objectToMove.transform.position; ParticleSystem.VelocityOverLifetimeModule groundVelocity = particlesShipWaves.GetComponent <ParticleSystem>().velocityOverLifetime; ParticleSystem.MinMaxCurve rate = new ParticleSystem.MinMaxCurve(); while (elapsedTime < seconds) { transform.position = Vector3.LerpUnclamped(startingPos, end, (elapsedTime / seconds)); if (!isMovingBack) { rate.constantMax = -2f;//Ship moves Front groundVelocity.x = rate; } else { rate.constantMax = 2f;//Ship moves Back groundVelocity.x = rate; } elapsedTime += Time.deltaTime; yield return(new WaitForEndOfFrame()); } transform.position = end; rate.constantMax = 0f;//Ship Stop groundVelocity.x = rate; myAudioSource.Stop(); }
} //--- void CalcSpeed() //calculating interconnected lifetime and speed //old approach, now can be changed by script or in editor only /*if (show_gui){ //if we control it using gui * clouds_lifetime= lifetime_base/day_speed; * * speed_k_value = 0.5f*day_speed*day_speed; * speed_k =speed_k_value*clouds_scale; * so = new SerializedObject(this.GetComponent<ParticleSystem>()); * so.FindProperty("VelocityModule.z.scalar").floatValue = speed_k; * so.ApplyModifiedProperties(); * print(speed_k); * //ParticleSystem.VelocityOverLifetimeModule p_vel = this.GetComponent<ParticleSystem>().velocityOverLifetime; * //ParticleSystem.MinMaxCurve rate = new ParticleSystem.MinMaxCurve(); * //rate.constantMax = speed_k; * //p_vel.z = rate; * } else{//if we use values from editor*/ { speed_k = speed_k_value * clouds_scale; ParticleSystem.VelocityOverLifetimeModule p_vel = this.GetComponent <ParticleSystem>().velocityOverLifetime; ParticleSystem.MinMaxCurve rate = new ParticleSystem.MinMaxCurve(); rate.constantMax = speed_k; p_vel.z = rate; //} }
private new void Start() { base.Start(); _healingSmokeParticle = transform.GetChild(1).GetChild(1).GetComponent <ParticleSystem>(); _velocity = _healingSmokeParticle.velocityOverLifetime; InvokeRepeating("FireTarget", 0f, 0.5f); }
/* * ================= * === PARTICLES === * ================= */ private void showMovementParticles() { /* * update state of "movement particles" every frame * (ground particles when moving over ground on the x axis) */ ParticleSystem ps = movementParticles.GetComponent <ParticleSystem>(); ParticleSystem.MainModule ps_main = ps.main; ParticleSystem.VelocityOverLifetimeModule ps_velocity = ps.velocityOverLifetime; if (movingX && grounded) { ps_velocity.x = (leftwards ? 11f : -11f); ps_velocity.y = 7f; ps_main.startLifetime = 2.7f; } else { ps_velocity.x = 0f; ps_velocity.y = 0f; ps_main.startLifetime = 0f; } }
private void EmitParticles(Vector2 direction) { if (!manager.BlockParticles) { return; } // set color ParticleSystem.MainModule main = ParticleSystem.main; main.startColor = SpriteRenderer.color; // set collision module ParticleSystem.CollisionModule collision = ParticleSystem.collision; collision.enabled = manager.BlockParticlesCollide; collision.mode = ParticleSystemCollisionMode.Collision2D; collision.type = ParticleSystemCollisionType.World; collision.bounce = 0.2f; // set velocity if (manager.BlockParticlesVelocity) { ParticleSystem.VelocityOverLifetimeModule velocity = ParticleSystem.velocityOverLifetime; ParticleSystem.MinMaxCurve x = velocity.x; x.constantMin = Mathf.Abs(x.constantMin) * Mathf.Sign(direction.x) + direction.x; x.constantMax = Mathf.Abs(x.constantMax) * Mathf.Sign(direction.x) + direction.x; ParticleSystem.MinMaxCurve y = velocity.y; y.constantMin = Mathf.Abs(y.constantMin) * Mathf.Sign(direction.y) + direction.y; y.constantMax = Mathf.Abs(y.constantMax) * Mathf.Sign(direction.y) + direction.y; velocity.x = x; velocity.y = y; } ParticleSystem.Emit(Random.Range(MinParticles, MaxParticles)); }
public void FloatWithArm() { KinectInterop.JointType handJoint = KinectInterop.JointType.HandRight; KinectInterop.JointType shoulderJoint = KinectInterop.JointType.ShoulderRight; KinectManager manager = KinectManager.Instance; if (manager && manager.IsInitialized()) { if (manager.IsUserDetected()) { long userId = manager.GetPrimaryUserID(); Vector3 handPos, shoulderPos; if (manager.IsJointTracked(userId, (int)shoulderJoint)) { shoulderPos = manager.GetJointPosition(userId, (int)shoulderJoint); if (manager.IsJointTracked(userId, (int)handJoint)) { handPos = manager.GetJointPosition(userId, (int)handJoint); armEffect = new Vector3(-3 * (handPos.x - shoulderPos.x), 3 * (handPos.y - shoulderPos.y), -3 * (handPos.z - shoulderPos.z)); ParticleSystem.VelocityOverLifetimeModule module = particle.velocityOverLifetime; } } } } }
void Start() { velocityModule = GetComponent <ParticleSystem>().velocityOverLifetime; animator = hero.GetComponent <Animator>(); animatorFire = heroFire.GetComponent <Animator>(); score = 0; }
IEnumerator BGMovementStep() { float duration_inverse = 1f / bg_movement_duration * 2f; float current = 0f; float orig_x = 0f; ParticleSystem.VelocityOverLifetimeModule volm = bg_stars.velocityOverLifetime; ParticleSystem.MinMaxCurve mmc = volm.x; while (current < 1f) { current += Time.deltaTime * duration_inverse; mmc.constantMin = Mathf.Lerp(orig_x, bg_star_motion_speed, current); mmc.constantMax = mmc.constantMin * 2f; volm.x = mmc; yield return(null); } while (current > 0f) { current -= Time.deltaTime * duration_inverse; mmc.constantMin = Mathf.Lerp(orig_x, bg_star_motion_speed, current); mmc.constantMax = mmc.constantMin * 2f; volm.x = mmc; yield return(null); } }
// Start is called before the first frame update void Start() { weatherParticleRenderer = GetComponent <ParticleSystemRenderer>(); availableWeatherTable.setWeather(0); velocityOverLifeTime = weatherParticles.velocityOverLifetime; StartCoroutine(RotateWeathers()); }
private void SetBubbles(float speedMultiplier, float rate) { ParticleSystem.VelocityOverLifetimeModule velocity = bubbleParticleSystem.velocityOverLifetime; velocity.speedModifierMultiplier = speedMultiplier; ParticleSystem.EmissionModule emission = bubbleParticleSystem.emission; emission.rateOverTime = normalspeed; }
// Start is called before the first frame update void Awake() { ParticleSystem.VelocityOverLifetimeModule vel = _particleSystem.velocityOverLifetime; velocity = Vector3.Magnitude(new Vector3(vel.xMultiplier, vel.yMultiplier, vel.zMultiplier)); Debug.Log(new Vector3(vel.xMultiplier, vel.yMultiplier, vel.zMultiplier)); worldSpaceScale = transform.localToWorldMatrix.lossyScale.magnitude; }
public void CreateHelix() { ps = GetComponent <ParticleSystem>(); ParticleSystem.VelocityOverLifetimeModule vel = ps.velocityOverLifetime; vel.enabled = true; vel.space = ParticleSystemSimulationSpace.Local; AnimationCurve curveX = new AnimationCurve(); for (int i = 0; i < resolution; i++) { float newTime = (i / (resolution - 1)); float value = 1 / (resolution - 1) * i * Mathf.Cos(newTime * 2 * Mathf.PI * frequency); curveX.AddKey(newTime, value); } vel.x = new ParticleSystem.MinMaxCurve(scaleXZ, curveX); AnimationCurve curveZ = new AnimationCurve(); for (int i = 0; i < resolution; i++) { float newTime = (i / (resolution - 1)); float value = 1 / (resolution - 1) * i * Mathf.Sin(newTime * 2 * Mathf.PI * frequency); curveZ.AddKey(newTime, value); } vel.z = new ParticleSystem.MinMaxCurve(scaleXZ, curveZ); }
protected override void ReadFromImpl(object obj) { base.ReadFromImpl(obj); ParticleSystem.VelocityOverLifetimeModule uo = (ParticleSystem.VelocityOverLifetimeModule)obj; enabled = uo.enabled; x = uo.x; y = uo.y; z = uo.z; xMultiplier = uo.xMultiplier; yMultiplier = uo.yMultiplier; zMultiplier = uo.zMultiplier; orbitalX = uo.orbitalX; orbitalY = uo.orbitalY; orbitalZ = uo.orbitalZ; orbitalXMultiplier = uo.orbitalXMultiplier; orbitalYMultiplier = uo.orbitalYMultiplier; orbitalZMultiplier = uo.orbitalZMultiplier; orbitalOffsetX = uo.orbitalOffsetX; orbitalOffsetY = uo.orbitalOffsetY; orbitalOffsetZ = uo.orbitalOffsetZ; orbitalOffsetXMultiplier = uo.orbitalOffsetXMultiplier; orbitalOffsetYMultiplier = uo.orbitalOffsetYMultiplier; orbitalOffsetZMultiplier = uo.orbitalOffsetZMultiplier; radial = uo.radial; radialMultiplier = uo.radialMultiplier; speedModifier = uo.speedModifier; speedModifierMultiplier = uo.speedModifierMultiplier; space = uo.space; }
public virtual void Start() { foreach (Transform t in this.transform) { ParticleSystem p = t.GetComponent <ParticleSystem>(); if (p) { // p.localVelocity.x *= speed; ParticleSystem.VelocityOverLifetimeModule velocityOverLifetimeModule = p.velocityOverLifetime; velocityOverLifetimeModule.x = velocityOverLifetimeModule.x.constant * this.speed; // p.minEnergy /= speed; // p.maxEnergy /= speed; ParticleSystem.MainModule mainModule = p.main; mainModule.startLifetime = mainModule.startLifetime.constant / this.speed; // p.minEmission *= speed; // p.maxEmission *= speed ParticleSystem.EmissionModule emissionModule = p.emission; emissionModule.rateOverTime = emissionModule.rateOverTime.constant * this.speed; ParticleSystemRenderer pr = (ParticleSystemRenderer)t.GetComponent(typeof(ParticleSystemRenderer)); if (pr && (pr.renderMode == ParticleSystemRenderMode.Stretch)) { pr.lengthScale = pr.lengthScale * (this.speed * 0.2f); } } } }
private void Update() { ParticleSystem.VelocityOverLifetimeModule velocityOverLifetimeModule = energy.velocityOverLifetime; Vector3 childOrbLocation = transform.InverseTransformPoint(Manager.Instance.UI.OrbManager.childOrb.transform.position); float maxLocation = Mathf.Max(childOrbLocation.x, childOrbLocation.y, childOrbLocation.z); childOrbLocation /= maxLocation; //velocityOverLifetimeModule.orbitalOffsetX = childOrbLocation.x; //velocityOverLifetimeModule.orbitalOffsetY = childOrbLocation.y; //velocityOverLifetimeModule.orbitalOffsetZ = childOrbLocation.z; ParticleSystem.MinMaxCurve x = velocityOverLifetimeModule.orbitalOffsetX; x.curve.RemoveKey(1); x.curve.AddKey(1, childOrbLocation.x); x.curveMultiplier = maxLocation; velocityOverLifetimeModule.orbitalOffsetX = x; ParticleSystem.MinMaxCurve y = velocityOverLifetimeModule.orbitalOffsetY; y.curve.RemoveKey(1); y.curve.AddKey(1, childOrbLocation.y); y.curveMultiplier = maxLocation; velocityOverLifetimeModule.orbitalOffsetY = y; ParticleSystem.MinMaxCurve z = velocityOverLifetimeModule.orbitalOffsetZ; z.curve.RemoveKey(1); z.curve.AddKey(1, childOrbLocation.z); z.curveMultiplier = maxLocation; velocityOverLifetimeModule.orbitalOffsetZ = z; }
public void spawnParticle(playerPlataformerController otherPlayer, int placeStruck) { var currentBlood = Instantiate(blood, otherPlayer.transform.root.GetChild(2).GetChild(placeStruck).GetComponent <BoxCollider2D>().transform.position, Quaternion.identity); currentBlood.transform.localScale = new Vector3(transform.root.GetChild(0).transform.localScale.x, 1, 1); ParticleSystem.ShapeModule editableShape = currentBlood.shape; editableShape.position = new Vector3(Random.Range(-1.0f, 1.0f), 0, Random.Range(-1.0f, 1.0f)); ParticleSystem.EmissionModule editableCount = currentBlood.emission; editableCount.SetBurst(0, new ParticleSystem.Burst(0, damage / 2)); ParticleSystem.VelocityOverLifetimeModule editableSpeed = currentBlood.velocityOverLifetime; editableSpeed.speedModifier = Mathf.Ceil(pushBackStrengh / 12f); if (placeStruck == 0) { Instantiate(hitSplash, new Vector3(otherPlayer.transform.position.x, otherPlayer.transform.position.y + 4f, 0), Quaternion.identity); } else if (placeStruck == 1) { Instantiate(hitSplash, new Vector3(otherPlayer.transform.position.x, otherPlayer.transform.position.y + 2f, 0), Quaternion.identity); } else { Instantiate(hitSplash, new Vector3(otherPlayer.transform.position.x, otherPlayer.transform.position.y - 1.5f, 0), Quaternion.identity); } }
// Start is called before the first frame update void Start() { indicator = transform.Find("Indicator").GetComponent <ParticleSystem>(); ParticleSystem.VelocityOverLifetimeModule particleVelocity = indicator.velocityOverLifetime; particleVelocity.y = thrownVelocity.magnitude / 2; Vector2 defaultVector = new Vector2(0, 1); float dot = Vector2.Dot(defaultVector, thrownVelocity); float det = defaultVector.x * thrownVelocity.y - defaultVector.y * thrownVelocity.x; float angle = Mathf.Atan2(det, dot); Debug.Log(angle); indicator.transform.Rotate(new Vector3(0, 0, 1), Mathf.Rad2Deg * angle); tick = delay; dtheta = spreadDegrees / (amount - 1); if (flip) { dtheta *= -1; newVelocity = RotateVec2(thrownVelocity, -spreadDegrees / 2); } else { newVelocity = RotateVec2(thrownVelocity, spreadDegrees / 2); } }
// Update is called once per frame void Update() { warmup_timer += Time.deltaTime; float warmup_percentage = Mathf.Clamp01(warmup_timer / warmup_length); // fire ParticleSystem.ShapeModule fire_shapeMod = fire.shape; ParticleSystem.EmissionModule fire_emissionMod = fire.emission; ParticleSystem.VelocityOverLifetimeModule fire_velocityMod = fire.velocityOverLifetime; ParticleSystem.MainModule fire_mainMod = fire.main; fire_shapeMod.scale = Vector3.Lerp(fire_minShapeScale, fire_maxShapeScale, warmup_percentage); fire_emissionMod.rateOverTime = fire_emissionRateRange.GetValue(warmup_percentage); fire_mainMod.simulationSpeed = fire_SimulationSpeedRange.GetValue(warmup_percentage); fire_velocityMod.orbitalOffsetY = fire_velocityOffsetYRange.GetValue(warmup_percentage); fire_velocityMod.speedModifierMultiplier = fire_velocitySpeedModRange.GetValue(warmup_percentage); fireLight.intensity = fire_lightIntensityRange.GetValue(warmup_percentage); // smoke ParticleSystem.ShapeModule smoke_shapeMod = smoke.shape; ParticleSystem.EmissionModule smoke_emissionMod = smoke.emission; ParticleSystem.MainModule smoke_mainMod = smoke.main; smoke_shapeMod.scale = Vector3.Lerp(smoke_minShapeScale, smoke_maxShapeScale, warmup_percentage); smoke_emissionMod.rateOverTime = smoke_emissionRateRange.GetValue(warmup_percentage); Color currentColor = smoke_mainMod.startColor.color; currentColor.a = smoke_alphaRange.GetValue(warmup_percentage); smoke_mainMod.startColor = currentColor; }
IEnumerator MoveOverSeconds(GameObject objectToMove, Vector3 end, float seconds) // Move the bike to the position that will be selected based on answer { float elapsedTime = 0; Vector3 startingPos = objectToMove.transform.position; ParticleSystem.VelocityOverLifetimeModule groundVelocity = particleGroundSmoke.GetComponent <ParticleSystem>().velocityOverLifetime; ParticleSystem.MinMaxCurve rate = new ParticleSystem.MinMaxCurve(); while (elapsedTime < seconds) { transform.position = Vector3.LerpUnclamped(startingPos, end, (elapsedTime / seconds)); mySecondaryAudioSource.volume = 0.6f; if (isMovingBack) //Just when moving front we accel { rate.constantMax = 1.61f; // groundVelocity.x = rate; } elapsedTime += Time.deltaTime; yield return(new WaitForEndOfFrame()); } transform.position = end; rate.constantMax = -2.61f;// groundVelocity.x = rate; mySecondaryAudioSource.volume = 0.0f; }
public void Initialize() { m_VelocityOverLifetimeModuleReference = m_ParticleSystemReference.velocityOverLifetime; //VelocityOverLifeTime : LinearX t_DefaultLinearVelocityOnX = m_VelocityOverLifetimeModuleReference.x; t_DefaultMaxLinearVelocityOnX.constant = t_DefaultLinearVelocityOnX.constant * maxChangeOfLinearVelocity; t_DefaultMaxLinearVelocityOnX.constantMin = t_DefaultLinearVelocityOnX.constantMin * maxChangeOfLinearVelocity; t_DefaultMaxLinearVelocityOnX.constantMax = t_DefaultLinearVelocityOnX.constantMax * maxChangeOfLinearVelocity; t_DefaultMaxLinearVelocityOnX.curveMultiplier = t_DefaultLinearVelocityOnX.curveMultiplier * maxChangeOfLinearVelocity; //VelocityOverLifeTime : LinearY t_DefaultLinearVelocityOnY = m_VelocityOverLifetimeModuleReference.y; t_DefaultMaxLinearVelocityOnY.constant = t_DefaultLinearVelocityOnY.constant * maxChangeOfLinearVelocity; t_DefaultMaxLinearVelocityOnY.constantMin = t_DefaultLinearVelocityOnY.constantMin * maxChangeOfLinearVelocity; t_DefaultMaxLinearVelocityOnY.constantMax = t_DefaultLinearVelocityOnY.constantMax * maxChangeOfLinearVelocity; t_DefaultMaxLinearVelocityOnY.curveMultiplier = t_DefaultLinearVelocityOnY.curveMultiplier * maxChangeOfLinearVelocity; //VelocityOverLifeTime : LinearZ t_DefaultLinearVelocityOnZ = m_VelocityOverLifetimeModuleReference.z; t_DefaultMaxLinearVelocityOnZ.constant = t_DefaultLinearVelocityOnZ.constant * maxChangeOfLinearVelocity; t_DefaultMaxLinearVelocityOnZ.constantMin = t_DefaultLinearVelocityOnZ.constantMin * maxChangeOfLinearVelocity; t_DefaultMaxLinearVelocityOnZ.constantMax = t_DefaultLinearVelocityOnZ.constantMax * maxChangeOfLinearVelocity; t_DefaultMaxLinearVelocityOnZ.curveMultiplier = t_DefaultLinearVelocityOnZ.curveMultiplier * maxChangeOfLinearVelocity; }
void Start() { ps = GetComponent <ParticleSystem>(); ParticleSystem.VelocityOverLifetimeModule vot = ps.velocityOverLifetime; if (Mathf.Abs(Camera.main.aspect - 16f / 9f) <= 0.01f) { vot.orbitalZ = orbitalZ_16x9; print("16x9"); } else if (Mathf.Abs(Camera.main.aspect - 16f / 10f) <= 0.01f) { vot.orbitalZ = orbitalZ_16x10; print("16x10"); } else if (Mathf.Abs(Camera.main.aspect - 3f / 2f) <= 0.01f) { vot.orbitalZ = orbitalZ_3x2; print("3x2"); } else if (Mathf.Abs(Camera.main.aspect - 5f / 4f) <= 0.01f) { vot.orbitalZ = orbitalZ_5x4; print("5x4"); } else if (Mathf.Abs(Camera.main.aspect - 4f / 3f) <= 0.01f) { vot.orbitalZ = orbitalZ_4x3; print("4x3"); } }
void FixedUpdate() { if (isControllable && Input.GetButton("Fire1")) { target = Camera.main.ScreenToWorldPoint(Input.mousePosition); } desired_velocity = target - body.position; distance = desired_velocity.magnitude; if (distance < slowingRadius) { desired_velocity = desired_velocity.normalized * max_velocity * (distance / Mathf.Pow(slowingRadius, slowingRate)) * Time.deltaTime; } else { desired_velocity = desired_velocity.normalized * max_velocity * Time.deltaTime; } steering = desired_velocity - velocity; steering = Vector2.ClampMagnitude(steering, max_force); steering = steering / mass; velocity = Vector2.ClampMagnitude(velocity + steering, max_speed); float angle = Mathf.Atan2(velocity.y, velocity.x) * Mathf.Rad2Deg; ParticleSystem.VelocityOverLifetimeModule vel = particle.velocityOverLifetime; vel.x = -velocity.magnitude; body.position += velocity; body.rotation = Mathf.Lerp(body.rotation, angle, angularSpeed * Time.deltaTime); }
protected virtual void GetParticleSystem() { _particleSystem = GetComponentInChildren <ParticleSystem>(); particleRenderer = GetComponentInChildren <ParticleSystemRenderer>(); // Modules - for ease of access mainModule = _particleSystem.main; collisionModule = _particleSystem.collision; colorBySpeedModule = _particleSystem.colorBySpeed; colorOverTimeModule = _particleSystem.colorOverLifetime; customDataModule = _particleSystem.customData; emissionModule = _particleSystem.emission; externalForcesModule = _particleSystem.externalForces; forceOverTimeModule = _particleSystem.forceOverLifetime; inheritVelocityModule = _particleSystem.inheritVelocity; lightsModule = _particleSystem.lights; limitVelocityOverTimeModule = _particleSystem.limitVelocityOverLifetime; noiseModule = _particleSystem.noise; rotationBySpeedModule = _particleSystem.rotationBySpeed; sizeBySpeedModule = _particleSystem.sizeBySpeed; sizeOverTimeModule = _particleSystem.sizeOverLifetime; trailModule = _particleSystem.trails; triggerModule = _particleSystem.trigger; shapeModule = _particleSystem.shape; velOverTimeModule = _particleSystem.velocityOverLifetime; }
private void Start() { // Particle System Explosion-------------------------- flare = explosion.GetComponent <ParticleSystem>(); explosionParticles = explosion.transform.GetChild(0).GetComponent <ParticleSystem>(); flareEmission = flare.emission; explosionEmission = explosionParticles.emission; explosionShape = explosionParticles.shape; explosionVOL = explosionParticles.velocityOverLifetime; //----------------------------------------------------- scoreScript = GameObject.Find("Game Manager").GetComponent <Score>(); // Generate random enemy health value in a range enemyHealth = Random.Range(enemyMinHealth, enemyMaxHealth + 1); enemyCurrentHealth = enemyHealth; // Make the scale of the enemy smaller or larger based on it's health enemyScale = (enemyHealth * 0.04f) + 0.5f; enemyScale = Mathf.Clamp(enemyScale, 0, 6); transform.localScale = new Vector3(enemyScale, enemyScale, enemyScale); // Put text in enemy that shows it's health enemyHealthText = new GameObject("Enemy Health"); enemyHealthText.transform.localScale = transform.localScale; t = enemyHealthText.AddComponent <TextMeshPro>(); t.alignment = TextAlignmentOptions.Center; t.fontSize = 5; t.text = enemyHealth.ToString(); t.color = new Color(0, 0, 0); }