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); } }
public ParticleEmitter Expand(float multiplier) { if (!didInit) { return(this); } shapeModule.radius *= multiplier; shapeModule.boxThickness *= multiplier; emissionModule.rateOverTime = MultiplyCurve(emissionModule.rateOverTime, multiplier); emissionModule.rateOverDistance = MultiplyCurve(emissionModule.rateOverTime, multiplier); for (int i = 0; i < emissionModule.burstCount; i++) { ParticleSystem.Burst burst = emissionModule.GetBurst(i); burst.count = MultiplyCurve(burst.count, multiplier); emissionModule.SetBurst(i, burst); } mainModule.startSize = MultiplyCurve(mainModule.startSize, Mathf.Pow(multiplier, 0.6f)); mainModule.startLifetime = MultiplyCurve(mainModule.startLifetime, Mathf.Pow(multiplier, 0.3f)); return(this); }
public void TurnOn(float percIntensity) { foreground.SetActive(true); emi.SetBurst(0, new ParticleSystem.Burst(0f, minParticles + percIntensity * (maxParticles - minParticles))); particles.Play(); on = true; }
/// <summary> /// Scales a gameobject with a line particle effect to reach between two points. Will get or create a new gameobject /// </summary> /// <param name="start">The start position of the line</param> /// <param name="end">The end position of the line</param> /// <param name="systems">The particle systems available to use</param> /// <param name="template">The template to use if a new gameobject is needed</param> private void ParticleLine(Vector3 start, Vector3 end, ICollection <ParticleSystem> systems, GameObject template) { ParticleSystem particle = systems.FirstOrDefault(system => !system.IsAlive()); if (particle is null) { GameObject go = Instantiate(template); particle = go.GetComponent <ParticleSystem>(); systems.Add(particle); } Transform lineTransform = particle.transform; Vector3 dir = end - start; float traceLength = dir.magnitude * 0.5f; lineTransform.position = start + 0.5f * dir; lineTransform.rotation = transform.rotation * Quaternion.Euler(0, 0, 90); ParticleSystem.ShapeModule shape = particle.shape; ParticleSystem.EmissionModule emission = particle.emission; emission.SetBurst(0, new ParticleSystem.Burst(0f, (ushort)(traceLength * 10))); shape.scale = new Vector3(traceLength, 1, 1); particle.Clear(); particle.Play(); }
public void SetParticleByDamages(float amount) { if (amount <= 0) { return; } burst.count = damagesToParticlesRatio * amount; emission.SetBurst(0, burst); }
// Bursts public void SputterTrail() { emissionModule.rateOverDistance = 0; emissionModule.burstCount = burstCount; for (int i = 0; i < burstCount; i++) { var burst = new ParticleSystem.Burst(i * 0.1f, 1, 1, 5, timeBetweenBursts); emissionModule.SetBurst(i, burst); } }
void InstantiateParticleSystem() { GameObject particleGO = Instantiate <GameObject>(AsteraX.AsteroidsSO.GetAsteroidParticlePrefab(), transform.position, Quaternion.identity); ParticleSystem particleSys = particleGO.GetComponent <ParticleSystem>(); ParticleSystem.MainModule main = particleSys.main; main.startLifetimeMultiplier = size * 0.5f; ParticleSystem.EmissionModule emitter = particleSys.emission; ParticleSystem.Burst burst = emitter.GetBurst(0); ParticleSystem.MinMaxCurve burstCount = burst.count; burstCount.constant = burstCount.constant * size; burst.count = burstCount; emitter.SetBurst(0, burst); }
public void bananaCollision(Collision2D _coll) { Vector2 tmpRelVec = _coll.relativeVelocity; //Debug.Log("tmpRelVec: " + tmpRelVec); if (tmpRelVec.magnitude > 2.25f && !particleSystem.isPlaying) { //Debug.Log("boooooooom!!!..."); transform.position = _coll.GetContact(0).point; mainModule.startSpeed = tmpRelVec.magnitude * 3f; mainModule.duration = tmpRelVec.magnitude / 2.5f; emissionModule.SetBurst(0, new ParticleSystem.Burst(0.0f, (short)(tmpRelVec.magnitude))); particleSystem.Play(); } }
private ParticleSystem CreateParticles(GameObject splashObj, float velocityY, float lifetime) { var particles = splashObj.GetComponent <ParticleSystem>(); particles.transform.localScale = transform.localScale; ParticleSystem.MainModule main = particles.main; main.startSpeed = 2 + Mathf.Abs(velocityY) * 0.5f; main.startLifetime = lifetime; ParticleSystem.EmissionModule particlesEmission = particles.emission; int particleCount = (int)Mathf.Abs(velocityY) * 2; particlesEmission.SetBurst(0, new ParticleSystem.Burst(0, particleCount, 1, 0.01f)); return(particles); }
public void PlayDestroyedParticleEffect() { float magnitude = (linePoints[1] - linePoints[0]).magnitude; GameObject instantiated = GameObject.Instantiate(team.resources.tronWallDestroyedPrefab, (linePoints[1] + linePoints[0]) / 2, transform.rotation); ParticleSystem ps = instantiated.EnsureComponent <ParticleSystem>(); ParticleSystem.MainModule main = ps.main; main.startColor = team.teamColor.color; ParticleSystem.ShapeModule shape = ps.shape; shape.radius = magnitude * .65f; ParticleSystem.EmissionModule emission = ps.emission; ParticleSystem.Burst burst = emission.GetBurst(0); burst.count = Mathf.Min(magnitude * burst.count.constant, maxParticlesOnDestroy); emission.SetBurst(0, burst); ps.Play(); }
// Update is called once per frame void Update() { testViePerso = VieMax - playerHP; //WIP VARIABLES X LIFE burstIntervalFlame = testViePerso * 30 / 100f; flameSizeMin = testViePerso * 0.25f / 100f; flameSizeMax = testViePerso * 0.4f / 100f; smokeEOT = testViePerso * 30 / 100f; smokeSizeMin = testViePerso * 1 / 100f; smokeSizeMax = testViePerso * 2 / 100f; smokeColor = testViePerso * 1 / 100f;; emberSizeMin = testViePerso * 0.1f / 100f; emberSizeMax = testViePerso * 0.15f / 100f; emberSpeedMin = testViePerso * 10 / 100f; emberSpeedMax = testViePerso * 18 / 100f; burstIntervalEmber = testViePerso * 30 / 100f; emberNbMin = (short)(testViePerso * 15 / 100f); emberNbMax = (short)(testViePerso * 30 / 100f); //Flame flameLifeMain.startSize = Random.Range(flameSizeMin, flameSizeMax); flameLifeEmission.SetBurst(0, new ParticleSystem.Burst(0f, 1, 1, 50, burstIntervalFlame)); //Smoke smokeEmission.rateOverTime = smokeEOT; smokeMain.startSize = Random.Range(smokeSizeMin, smokeSizeMax); smokeMain.startColor = Color.Lerp(colorStart, colorEnd, smokeColor); //Ember emberMain.startSize = Random.Range(emberSizeMin, emberSizeMax); emberMain.startSpeed = Random.Range(emberSpeedMin, emberSpeedMax); emberEmission.SetBurst(0, new ParticleSystem.Burst(0f, emberNbMin, emberNbMax, 50, burstIntervalEmber)); //smokeColorOLT.color = SmokeGrandient; //Gradient grad = new Gradient (); //grad.SetKeys( new GradientColorKey[] {new GradientColorKey(Color.blue, 0.0f), new GradientColorKey(Color.red, 1.0f)}, new GradientAlphaKey[]{new GradientAlphaKey(1.0f,0.0f), new GradientAlphaKey(0.0f,1.0f)}); }
void InstantiateParticleSystem(int ndx) { if (particleSystems.Length <= ndx) { return; } GameObject particleGO = Instantiate <GameObject>(particleSystems[ndx], transform.position, Quaternion.identity); ParticleSystem particleSys = particleGO.GetComponent <ParticleSystem>(); ParticleSystem.MainModule main = particleSys.main; main.startLifetimeMultiplier = size * 0.5f; ParticleSystem.EmissionModule emitter = particleSys.emission; ParticleSystem.Burst burst = emitter.GetBurst(0); ParticleSystem.MinMaxCurve burstCount = burst.count; burstCount.constant = burstCount.constant * size; burst.count = burstCount; emitter.SetBurst(0, burst); Destroy(particleGO, 4f); }
public void Click() { if (hunger - 1 >= 0) { Score.scoreIncrease(); hunger -= 1; OnHungerLowered?.Invoke(hunger, maxHunger + bonusHunger); emission.SetBurst(0, new ParticleSystem.Burst(0, Score.clickPow)); poopParticles.Play(); float pitch = (float)(rnd.Next(40, 60)) / 50; audio.pitch = pitch; audio.Play(); } else { Score.AwarenessTextShow("F**k can't poop while hungry!"); } }
private void CopyParticle(ParticleSystem part, ParticleSystem newPart) { ParticleSystem.MainModule main = part.main; main.duration = newPart.main.duration; main.startLifetime = newPart.main.startLifetime; main.startSpeed = newPart.main.startSpeed; main.startSize = newPart.main.startSize; main.startColor = newPart.main.startColor; ParticleSystem.EmissionModule emis = part.emission; emis.rateOverTime = newPart.emission.rateOverTime; emis.rateOverDistance = newPart.emission.rateOverDistance; emis.burstCount = newPart.emission.burstCount; emis.SetBurst(0, newPart.emission.GetBurst(0)); ParticleSystem.ShapeModule shape = part.shape; shape.shapeType = newPart.shape.shapeType; shape.radius = newPart.shape.radius; shape.radiusThickness = newPart.shape.radiusThickness; shape.arc = newPart.shape.arc; shape.arcMode = newPart.shape.arcMode; shape.arcSpeed = newPart.shape.arcSpeed; shape.position = newPart.shape.position; shape.rotation = newPart.shape.rotation; ParticleSystem.RotationOverLifetimeModule rot = part.rotationOverLifetime; rot.enabled = newPart.rotationOverLifetime.enabled; rot.z = newPart.rotationOverLifetime.z; ParticleSystem.TextureSheetAnimationModule tex = part.textureSheetAnimation; tex.enabled = newPart.textureSheetAnimation.enabled; if (tex.enabled) { tex.mode = newPart.textureSheetAnimation.mode; tex.SetSprite(0, newPart.textureSheetAnimation.GetSprite(0)); } ParticleSystem.SubEmittersModule sub = part.subEmitters; sub.enabled = newPart.subEmitters.enabled; if (sub.enabled) { sub.AddSubEmitter(newPart.subEmitters.GetSubEmitterSystem(0), newPart.subEmitters.GetSubEmitterType(0), newPart.subEmitters.GetSubEmitterProperties(0)); } }
private void DisableSelf() { if (!edgeCollider.enabled) { return; } edgeCollider.enabled = false; lineRenderer.enabled = false; GameObject instatiated = GameObject.Instantiate(GameManager.Instance.neutralResources.tronWallDestroyedPrefab, transform.position, transform.rotation); ParticleSystem ps = instatiated.EnsureComponent <ParticleSystem>(); ParticleSystem.MainModule main = ps.main; ParticleSystem.ShapeModule shape = ps.shape; shape.radius = explosionRadius; ParticleSystem.EmissionModule emission = ps.emission; ParticleSystem.Burst burst = emission.GetBurst(0); burst.count = numberOfParticles; emission.SetBurst(0, burst); ps.Play(); }
// Token: 0x06001296 RID: 4758 RVA: 0x0005B0F4 File Offset: 0x000592F4 public void ProcessEffectElement(float radius, float minimumValidRadius) { if (this.particleSystem) { if (this.particleSystemOverrideMaterial) { ParticleSystemRenderer component = this.particleSystem.GetComponent <ParticleSystemRenderer>(); if (this.particleSystemOverrideMaterial) { component.material = this.particleSystemOverrideMaterial; } } ParticleSystem.EmissionModule emission = this.particleSystem.emission; int num = (int)emission.GetBurst(0).maxCount + (int)((radius - minimumValidRadius) * this.bonusEmissionPerBonusRadius); emission.SetBurst(0, new ParticleSystem.Burst(0f, (float)num)); if (this.particleSystemEmitParticles) { this.particleSystem.gameObject.SetActive(true); return; } this.particleSystem.gameObject.SetActive(false); } }
public override void SetIntensity(float value, bool loopOnly = false) { if (!loopOnly || (loopOnly && step == Step.Loop)) { currentValue = intensityCurve.Evaluate(value); if (useScaleCurve) { float scale = scaleCurve.Evaluate(value); transform.localScale = new Vector3(scale, scale, scale); } foreach (EffectParticleChild p in childs) { ParticleSystem.MainModule mainModule = p.particleSystem.main; if (p.duration && !p.particleSystem.isPlaying) { mainModule.duration = p.curveDuration.Evaluate(currentValue); } if (p.lifeTime) { minMaxCurve.mode = ParticleSystemCurveMode.TwoConstants; float lifeTime = p.curveLifeTime.Evaluate(currentValue); minMaxCurve.constantMin = Mathf.Clamp(lifeTime - p.randomRangeLifeTime, 0, Mathf.Infinity); minMaxCurve.constantMax = Mathf.Clamp(lifeTime, 0, Mathf.Infinity); mainModule.startLifetime = minMaxCurve; } if (p.speed) { minMaxCurve.mode = ParticleSystemCurveMode.TwoConstants; float speed = p.curveSpeed.Evaluate(currentValue); minMaxCurve.constantMin = minMaxCurve.constantMin = Mathf.Clamp(speed - p.randomRangeSpeed, 0, Mathf.Infinity); minMaxCurve.constantMax = speed; mainModule.startSpeed = minMaxCurve; } if (p.size) { minMaxCurve.mode = ParticleSystemCurveMode.TwoConstants; float size = p.curveSize.Evaluate(currentValue); minMaxCurve.constantMin = Mathf.Clamp(size - p.randomRangeSize, 0, Mathf.Infinity); minMaxCurve.constantMax = Mathf.Clamp(size, 0, Mathf.Infinity); mainModule.startSize = minMaxCurve; } if (p.shapeRadius) { var shape = p.particleSystem.shape; shape.radius = p.curveShapeRadius.Evaluate(currentValue); } if (p.rate) { minMaxCurve.mode = ParticleSystemCurveMode.TwoConstants; float rate = p.curveRate.Evaluate(currentValue); minMaxCurve.constantMin = Mathf.Clamp(rate - p.randomRangeRate, 0, Mathf.Infinity); minMaxCurve.constantMax = Mathf.Clamp(rate, 0, Mathf.Infinity); ParticleSystem.EmissionModule particleEmission = p.particleSystem.emission; particleEmission.rateOverTime = minMaxCurve; } if (p.burst) { short burst = (short)p.curveBurst.Evaluate(value); ParticleSystem.Burst particleBurst = new ParticleSystem.Burst(0, (short)Mathf.Clamp(burst - p.randomRangeBurst, 0, Mathf.Infinity), (short)Mathf.Clamp(burst, 0, Mathf.Infinity)); ParticleSystem.EmissionModule particleEmission = p.particleSystem.emission; particleEmission.SetBurst(0, particleBurst); } if (p.velocityOverLifetime) { float rate = p.curvevelocityOverLifetime.Evaluate(currentValue); minMaxCurve.constantMin = Mathf.Clamp(rate, 0, Mathf.Infinity); minMaxCurve.constantMax = Mathf.Clamp(rate, 0, Mathf.Infinity); ParticleSystem.VelocityOverLifetimeModule velocityModule = p.particleSystem.velocityOverLifetime; velocityModule.speedModifier = minMaxCurve; } if (p.lightIntensity) { var lights = p.particleSystem.lights; lights.intensityMultiplier = p.curveLightIntensity.Evaluate(currentValue); } // Set start color gradient ParticleSystem.MinMaxGradient minMaxGradient = mainModule.startColor; if (p.linkStartGradient == EffectTarget.Main && currentMainGradient != null) { minMaxGradient.mode = ParticleSystemGradientMode.Gradient; minMaxGradient.gradient = currentMainGradient; } if (p.linkStartGradient == EffectTarget.Secondary && currentSecondaryGradient != null) { minMaxGradient.mode = ParticleSystemGradientMode.Gradient; minMaxGradient.gradient = currentSecondaryGradient; } // Set start color if (p.linkStartColor == EffectTarget.Main && currentMainGradient != null) { minMaxGradient.mode = ParticleSystemGradientMode.Color; if (p.ignoreAlpha) { Color newColor = currentMainGradient.Evaluate(currentValue); minMaxGradient.color = new Color(newColor.r, newColor.g, newColor.b, minMaxGradient.color.a); } else { minMaxGradient.color = currentMainGradient.Evaluate(currentValue); } } if (p.linkStartColor == EffectTarget.Secondary && currentSecondaryGradient != null) { minMaxGradient.mode = ParticleSystemGradientMode.Color; if (p.ignoreAlpha) { Color newColor = currentSecondaryGradient.Evaluate(currentValue); minMaxGradient.color = new Color(newColor.r, newColor.g, newColor.b, minMaxGradient.color.a); } else { minMaxGradient.color = currentSecondaryGradient.Evaluate(currentValue); } } mainModule.startColor = minMaxGradient; // Set material color bool updatePropertyBlock = false; if (p.linkBaseColor == EffectTarget.Main && currentMainGradient != null) { p.materialPropertyBlock.SetColor("_BaseColor", currentMainGradient.Evaluate(currentValue)); updatePropertyBlock = true; } else if (p.linkBaseColor == EffectTarget.Secondary && currentSecondaryGradient != null) { p.materialPropertyBlock.SetColor("_BaseColor", currentSecondaryGradient.Evaluate(currentValue)); updatePropertyBlock = true; } if (p.linkTintColor == EffectTarget.Main && currentMainGradient != null) { p.materialPropertyBlock.SetColor("_TintColor", currentMainGradient.Evaluate(currentValue)); updatePropertyBlock = true; } else if (p.linkTintColor == EffectTarget.Secondary && currentSecondaryGradient != null) { p.materialPropertyBlock.SetColor("_TintColor", currentSecondaryGradient.Evaluate(currentValue)); updatePropertyBlock = true; } if (p.linkEmissionColor == EffectTarget.Main && currentMainGradient != null) { p.materialPropertyBlock.SetColor("_EmissionColor", currentMainGradient.Evaluate(currentValue)); updatePropertyBlock = true; } else if (p.linkEmissionColor == EffectTarget.Secondary && currentSecondaryGradient != null) { p.materialPropertyBlock.SetColor("_EmissionColor", currentSecondaryGradient.Evaluate(currentValue)); updatePropertyBlock = true; } if (updatePropertyBlock) { p.particleRenderer.SetPropertyBlock(p.materialPropertyBlock); } } } }
protected override void LateUpdate() { currentProfielValues[0] = Mathf.Clamp(playerAimModule.arrowChargingState * 2.5f, minBurstCount, maxBurstCount); ParticleSystem.Burst burst = new ParticleSystem.Burst(0.01f, currentProfielValues[0]); emissionModule.SetBurst(0, burst); }