protected override void ReadFromImpl(object obj) { base.ReadFromImpl(obj); ParticleSystem.CollisionModule uo = (ParticleSystem.CollisionModule)obj; enabled = uo.enabled; type = uo.type; mode = uo.mode; dampen = uo.dampen; dampenMultiplier = uo.dampenMultiplier; bounce = uo.bounce; bounceMultiplier = uo.bounceMultiplier; lifetimeLoss = uo.lifetimeLoss; lifetimeLossMultiplier = uo.lifetimeLossMultiplier; minKillSpeed = uo.minKillSpeed; maxKillSpeed = uo.maxKillSpeed; collidesWith = uo.collidesWith; enableDynamicColliders = uo.enableDynamicColliders; maxCollisionShapes = uo.maxCollisionShapes; quality = uo.quality; voxelSize = uo.voxelSize; radiusScale = uo.radiusScale; sendCollisionMessages = uo.sendCollisionMessages; colliderForce = uo.colliderForce; multiplyColliderForceByCollisionAngle = uo.multiplyColliderForceByCollisionAngle; multiplyColliderForceByParticleSpeed = uo.multiplyColliderForceByParticleSpeed; multiplyColliderForceByParticleSize = uo.multiplyColliderForceByParticleSize; }
protected override object WriteToImpl(object obj) { obj = base.WriteToImpl(obj); ParticleSystem.CollisionModule uo = (ParticleSystem.CollisionModule)obj; uo.enabled = enabled; uo.type = type; uo.mode = mode; uo.dampen = dampen; uo.dampenMultiplier = dampenMultiplier; uo.bounce = bounce; uo.bounceMultiplier = bounceMultiplier; uo.lifetimeLoss = lifetimeLoss; uo.lifetimeLossMultiplier = lifetimeLossMultiplier; uo.minKillSpeed = minKillSpeed; uo.maxKillSpeed = maxKillSpeed; uo.collidesWith = collidesWith; uo.enableDynamicColliders = enableDynamicColliders; uo.maxCollisionShapes = maxCollisionShapes; uo.quality = quality; uo.voxelSize = voxelSize; uo.radiusScale = radiusScale; uo.sendCollisionMessages = sendCollisionMessages; uo.colliderForce = colliderForce; uo.multiplyColliderForceByCollisionAngle = multiplyColliderForceByCollisionAngle; uo.multiplyColliderForceByParticleSpeed = multiplyColliderForceByParticleSpeed; uo.multiplyColliderForceByParticleSize = multiplyColliderForceByParticleSize; return(uo); }
void Start() { //To find the angles between bullet bursts FindAngleStep(BulletsNumber); bulletsLifetime = Distance / Speed; ps = gameObject.GetComponent <ParticleSystem> (); ParticleSystem.MainModule psm = ps.main; psm.startLifetime = bulletsLifetime; ParticleSystem.EmissionModule pse = ps.emission; pse.enabled = false; // This will be used to turn collision on and changing the collider size so // that you can easily add a new script & not worry about doing it manually. ParticleSystem.CollisionModule psc = ps.collision; psc.enabled = true; psc.radiusScale = ColliderSize; psc.sendCollisionMessages = true; psc.type = ParticleSystemCollisionType.World; psc.mode = ParticleSystemCollisionMode.Collision2D; //This ensure that the bullets are killed on collision psc.maxKillSpeed = 0; ParticleSystemRenderer psr = GetComponent <ParticleSystemRenderer>(); psr.material = BulletsMaterial; }
void Start() { if (Resources.Load("LaserMaterial/_laser") != null && laserMaterial == null) { laserMaterial = (Material)Resources.Load("LaserMaterial/_laser"); } _ps = GetComponent <ParticleSystem>(); _pr = (ParticleSystemRenderer)GetComponent <Renderer>(); Intensity = 1000; emmision = _ps.emission; emmision.enabled = true; shape = _ps.shape; sizeOverLifeTime = _ps.sizeOverLifetime; colorOverLifeTime = _ps.colorOverLifetime; collision = _ps.collision; _material = GetComponent <ParticleSystemRenderer>().sharedMaterial; _pr.material = laserMaterial; sizeOverLifeTimeCurve.mode = ParticleSystemCurveMode.Constant; generator = new Generator(this); tempColor = (Color.r == 0 && Color.g == 0 && Color.b == 0 && Color.a == 0) ? Color.white : Color; _ps.hideFlags = HideFlags.NotEditable; _ps.Play(); }
private void OnTriggerEnter(Collider other) { Debug.Log(other.gameObject.name); if (other.gameObject.name == "Sphere") { ParticleSystem.CollisionModule pCollision = sanitizerParticles.collision; newCCube = Instantiate(colliderCube); newCCube.GetComponent <FollowParentObject>().myParent = other.transform; pCollision.SetPlane(0, newCCube.transform); } //----- Checks which hand is in collision zone ----- if (other.transform.parent.transform.parent.name == "RightController") { activeHand = "Right"; Dispense(); Debug.Log("Right"); } else if (other.transform.parent.transform.parent.name == "LeftController") { activeHand = "Left"; Dispense(); Debug.Log("Left"); } }
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; }
public static void ParticleCollisionSettings(this ParticleSystem PS, bool enabled = true, float ColliderForce = 0f, float RadiusScale = 0f, ParticleSystemCollisionMode Mode = ParticleSystemCollisionMode.Collision3D, ParticleSystemCollisionQuality Quality = ParticleSystemCollisionQuality.High, ParticleSystemCollisionType Type = ParticleSystemCollisionType.World, bool DynamicColliders = true, bool SendMessages = true, string[] MaskNames = null, // Set Outside, selects Default if none) float BounceMin = 0f, float BounceMax = 0f ) { ParticleSystem.CollisionModule collisionModule = PS.collision; // Collision Settings collisionModule.enabled = enabled; collisionModule.bounce = new ParticleSystem.MinMaxCurve(BounceMin, BounceMax); collisionModule.colliderForce = ColliderForce; collisionModule.radiusScale = RadiusScale; collisionModule.mode = Mode; collisionModule.quality = Quality; collisionModule.type = Type; collisionModule.collidesWith = GetLayer(MaskNames); collisionModule.enableDynamicColliders = DynamicColliders; collisionModule.sendCollisionMessages = SendMessages; }
public void AttachToPlayer(PlayerController pc) { player = pc; ParticleSystem.CollisionModule collisionModule = trailParticleSystem.collision; LayerMask layer0 = 1 << LayerMask.NameToLayer("Player0"); LayerMask layer1 = 1 << LayerMask.NameToLayer("Player1"); LayerMask layer2 = 1 << LayerMask.NameToLayer("Player2"); LayerMask layer3 = 1 << LayerMask.NameToLayer("Player3"); switch (player.GetID()) { case 0: collisionModule.collidesWith = layer1 | layer2 | layer3; break; case 1: collisionModule.collidesWith = layer0 | layer2 | layer3; break; case 2: collisionModule.collidesWith = layer0 | layer1 | layer3; break; case 3: collisionModule.collidesWith = layer0 | layer1 | layer2; break; default: break; } }
private void SetupParticleSystem() { waterParticles = GetComponent <ParticleSystem>(); waterParticles.startLifetime = 1.3f; waterParticles.startSpeed = 10; waterParticles.startSize = 3; waterParticles.startColor = new Color(66f / 255f, 208f / 255f, 1, 1); waterParticles.gravityModifier = 9.8f; waterParticles.simulationSpace = ParticleSystemSimulationSpace.World; waterParticles.maxParticles = 750; ParticleSystem.EmissionModule emission = waterParticles.emission; emission.enabled = true; emission.rate = 500; ParticleSystem.ShapeModule shape = waterParticles.shape; shape.enabled = true; shape.shapeType = ParticleSystemShapeType.ConeVolume; shape.angle = 0; shape.radius = 0.01f; shape.length = 3; ParticleSystem.CollisionModule collision = waterParticles.collision; collision.enabled = true; collision.type = ParticleSystemCollisionType.World; collision.mode = ParticleSystemCollisionMode.Collision3D; collision.bounce = 0; collision.radiusScale = 0.3f; collision.enableInteriorCollisions = true; collision.sendCollisionMessages = true; }
void OnEffectStop() { m_particleDamage.enabled = false; ParticleSystem.CollisionModule module = m_particleSystem.collision; module.enabled = false; }
public override void AddCollisionLayer(int layer) { ParticleSystem.CollisionModule collision = this.flameParticleSystem.collision; collision.collidesWith = LayerMasksUtils.AddLayerToMask((int)collision.collidesWith, layer); collision = this.smokeParticleSystem.collision; collision.collidesWith = LayerMasksUtils.AddLayerToMask((int)collision.collidesWith, layer); }
public override object WriteTo(object obj) { obj = base.WriteTo(obj); if (obj == null) { return(null); } ParticleSystem.CollisionModule o = (ParticleSystem.CollisionModule)obj; if (m_planes == null) { for (int i = 0; i < o.maxPlaneCount; ++i) { o.SetPlane(i, null); } } else { for (int i = 0; i < Mathf.Min(o.maxPlaneCount, m_planes.Length); ++i) { o.SetPlane(i, FromID <Transform>(m_planes[i])); } } return(obj); }
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); } }
public void setParticleCollision() { ParticleSystem ps; if (cube.gameObject.activeInHierarchy) { ps = cube.GetComponent <ParticleSystem>(); } else { ps = sphere.GetComponent <ParticleSystem>(); } ps.gravityModifier = 1; ParticleSystem.ColorOverLifetimeModule colorOverLT = ps.colorOverLifetime; colorOverLT.enabled = true; colorOverLT.color = colorOverLifeTiime; ParticleSystem.CollisionModule col = ps.collision; col.enabled = true; col.dampen = 0.2f; col.bounce = 1; ps.Clear(); }
public void SetDefaultRain() { if (CoopPeerStarter.DedicatedHost) { return; } if (!this._rainParticles) { this._rainParticles = base.transform.GetComponent <ParticleSystem>(); } ParticleSystem.MainModule main = this._rainParticles.main; main.duration = this._defaultDuration; main.startLifetimeMultiplier = 1f; main.maxParticles = this._defaultMaxParticles; this._rainParticles.shape.radius = this._defaultRadius; ParticleSystem.CollisionModule collision = this._rainParticles.collision; if (LocalPlayer.ScriptSetup.targetInfo.inYacht) { collision.quality = ParticleSystemCollisionQuality.High; } else { collision.quality = ParticleSystemCollisionQuality.Medium; } }
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)); }
private void MapCollisionParameters(ParticleSystem pSystem, int i) { ParticleSystem.CollisionModule collisionModule = pSystem.collision; try { collisionModule.enabled = GetBoolParam(i, "collision_enabled"); } catch (NullReferenceException) { collisionModule.enabled = false; return; } collisionModule.type = (ParticleSystemCollisionType)GetIntParam(i, "collision_type"); collisionModule.mode = (ParticleSystemCollisionMode)GetIntParam(i, "collision_mode"); collisionModule.quality = (ParticleSystemCollisionQuality)GetIntParam(i, "collision_quality"); collisionModule.enableDynamicColliders = GetBoolParam(i, "collision_enableDynamicColliders"); collisionModule.multiplyColliderForceByCollisionAngle = GetBoolParam(i, "collision_multiplyByCollisionAngle"); collisionModule.multiplyColliderForceByParticleSize = GetBoolParam(i, "collision_multiplyByParticleSize"); collisionModule.multiplyColliderForceByParticleSpeed = GetBoolParam(i, "collision_multiplyByParticleSpeed"); collisionModule.sendCollisionMessages = GetBoolParam(i, "collision_sendCollisionMessages"); collisionModule.minKillSpeed = GetFloatParam(i, "collision_minKillSpeed"); collisionModule.maxKillSpeed = GetFloatParam(i, "collision_maxKillSpeed"); collisionModule.radiusScale = GetFloatParam(i, "collision_radiusScale"); collisionModule.colliderForce = GetFloatParam(i, "collision_colliderForce"); collisionModule.lifetimeLoss = NodeFXUtilities.InterpretStringToCurve(GetStringParam(i, "collision_lifetimeLoss")); collisionModule.bounce = NodeFXUtilities.InterpretStringToCurve(GetStringParam(i, "collision_bounce")); collisionModule.dampen = NodeFXUtilities.InterpretStringToCurve(GetStringParam(i, "collision_dampen")); }
private void SetupMainThruster() { mainThruster = GetComponent <ParticleSystem>(); #region Main Properties mainThruster.startLifetime = 0.25f; mainThruster.startSpeed = thrusterStrength; mainThruster.startSize = 2.5f; mainThruster.gravityModifier = 9.8f; mainThruster.simulationSpace = ParticleSystemSimulationSpace.World; mainThruster.scalingMode = ParticleSystemScalingMode.Shape; mainThruster.playOnAwake = false; mainThruster.maxParticles = 0; #endregion #region Emission Module ParticleSystem.EmissionModule emission = mainThruster.emission; emission.enabled = true; emission.rate = 0; #endregion #region Shape Module ParticleSystem.ShapeModule shape = mainThruster.shape; shape.enabled = true; shape.shapeType = ParticleSystemShapeType.Cone; shape.angle = 0; shape.radius = 0.01f; #endregion #region Color Over Lifetime Module ParticleSystem.ColorOverLifetimeModule colorOverLifetime = mainThruster.colorOverLifetime; colorOverLifetime.enabled = true; Gradient gradient = new Gradient(); gradient.SetKeys(new GradientColorKey[] { new GradientColorKey(mainColor, 0.3f), new GradientColorKey(Color.white, 1f) }, new GradientAlphaKey[] { new GradientAlphaKey(1, 0), new GradientAlphaKey(0, 1) }); colorOverLifetime.color = gradient; #endregion #region Size Over Lifetime Module ParticleSystem.SizeOverLifetimeModule sizeOverLifetime = mainThruster.sizeOverLifetime; sizeOverLifetime.enabled = true; sizeOverLifetime.separateAxes = false; AnimationCurve curve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)); sizeOverLifetime.size = new ParticleSystem.MinMaxCurve(1, curve); #endregion #region Collision Module ParticleSystem.CollisionModule collision = mainThruster.collision; collision.enabled = true; collision.type = ParticleSystemCollisionType.World; collision.mode = ParticleSystemCollisionMode.Collision2D; collision.bounce = 0; collision.radiusScale = 0.5f; collision.enableInteriorCollisions = false; collision.sendCollisionMessages = true; LayerMask layerMask = new LayerMask(); layerMask.value = (1 << LayerMask.NameToLayer("World")) | (1 << LayerMask.NameToLayer("Vehicle") | (1 << LayerMask.NameToLayer("Object"))); collision.collidesWith = layerMask; #endregion #region Renderer Module ParticleSystemRenderer renderer = GetComponent <ParticleSystemRenderer>(); renderer.material = new Material(Resources.Load <Material>("Materials/Particles/Thruster")); renderer.sortingFudge = 10; #endregion }
public void UpdateOnHitSettings(Characters.Character owner, Vector3 dir, LayerMask ignore, float baseDamage) { this.owner = owner; this.baseDamage = baseDamage; incomingDirection = dir; ParticleSystem.CollisionModule coll = part.collision; coll.collidesWith = ~ignore; }
void OnParticleCollision(GameObject col) { // Turn off collisions for particle system, so Rudess doesn't keep getting hit. ParticleSystem.CollisionModule cm = col.GetComponent <ParticleSystem> ().collision; cm.enabled = false; TakeDamage(); }
public void setIgnoreLayer(int layerToIgnore) { // Unity is gay and doesn't let us modify particle system at runtime. // So we make our own editable reference to the same data space ParticleSystem.CollisionModule editableCollModule = getPSystem().collision; editableCollModule.collidesWith = ignoreLayer(layerToIgnore); }
public override void Aquire(PlayerController playerController) { // Detatch the old trail. playerController.particleTrail.SetExistingParticlesStartLifetime(float.PositiveInfinity); // When changing the parent, even though keepWorldSpace = true, this changes the position ever so slightly. // This can rarely lead to an unwanted collision, so we temporarily disable collisions during this move. ParticleSystem.CollisionModule collision = playerController.particleTrail.collision; collision.enabled = false; playerController.particleTrail.transform.SetParent(null, true); GameManager.Instance.StartCoroutine(renableCollision()); IEnumerator renableCollision() { yield return(new WaitForSecondsRealtime(0.1f)); // These three lines are less stupid than they seem. // This is for re-enabling the old and the new tail. // I'm not sure why both need to be re-enabled. Theoretically only the old tail should need to be re-enabled. // This seems to fix a bug where the new tail had no collsions. collision.enabled = true; collision = playerController.particleTrail.collision; collision.enabled = true; } ParticleSystem oldTrail = playerController.particleTrail; playerController.GetNewTrail(); GameManager.Instance.StartCoroutine(clearSkillUI()); IEnumerator clearSkillUI() { yield return(new WaitForSecondsRealtime(1f)); playerController.ui?.ClearSkillUIFor(this); } // Increase the player's tail growth for a short while to sort of catch them back up to their old length. playerController.growSpeed *= 2; GameManager.Instance.StartCoroutine(resetGrowSpeed()); IEnumerator resetGrowSpeed() { yield return(new WaitForSecondsRealtime(5f)); playerController.growSpeed /= 2f; } // Delete the tails after some time if in Endless mode or else the map will be just too polluted. if (GameManager.GameMode == GameMode.Endless) { GameManager.Instance.StartCoroutine(decay()); IEnumerator decay() { yield return(new WaitForSecondsRealtime(decayDelay)); oldTrail.SetExistingParticlesStartLifetime(1f); } } }
private void Awake() { fountainMain = fountain.main; dropsMain = drops.main; subEmitterMain = subEmitter.main; dropsEmission = drops.emission; dropCollision = drops.collision; audioS = GetComponent <AudioSource>(); audioS.loop = true; }
private void Awake() { DialogueManager dm = FindObjectOfType <DialogueManager>(); dm.OnOpenWindow += DisableInput; dm.OnCloseWindow += EnableInput; canClick = true; UIactive = false; particleEmission = particleSys.emission; particleCollision = particleSys.collision; }
// Set collision for dust public static void SetCollisionDust(ParticleSystem.CollisionModule psCollision, RFParticleCollisionDust coll) { psCollision.enabled = true; psCollision.type = ParticleSystemCollisionType.World; psCollision.collidesWith = (int)coll.collidesWith - 1; psCollision.quality = coll.quality; psCollision.radiusScale = coll.radiusScale; psCollision.dampenMultiplier = 0f; psCollision.bounceMultiplier = 0f; psCollision.enableDynamicColliders = false; }
void Start() { this.particleSystemComponent = this.GetComponent <ParticleSystem>(); // Store CollisionModule in temp variable, to be able to assign to collidesWith below: ParticleSystem.CollisionModule collisionModule = this.particleSystemComponent.collision; if (collisionModule.collidesWith != this.hittableLayers) { Debug.LogWarning("Setting ParticleSystem collidesWith to DamageDealer hittableLayers"); collisionModule.collidesWith = this.hittableLayers; } }
void OnEffectPlay() { m_particleSystem.Play(); m_particleDamage.enabled = true; if (m_audio) { m_audio.Play(); } ParticleSystem.CollisionModule module = m_particleSystem.collision; module.enabled = true; }
/// ///////////////////////////////////////////////////////// /// Collision /// ///////////////////////////////////////////////////////// // Set collision for debris public static void SetCollisionDebris(ParticleSystem.CollisionModule psCollision, RFParticleCollisionDebris coll) { psCollision.enabled = true; psCollision.type = ParticleSystemCollisionType.World; psCollision.collidesWith = (int)coll.collidesWith - 1; psCollision.quality = coll.quality; psCollision.radiusScale = coll.radiusScale; psCollision.dampen = new ParticleSystem.MinMaxCurve(coll.dampenMin, coll.dampenMax); psCollision.bounce = new ParticleSystem.MinMaxCurve(coll.bounceMin, coll.bounceMax); //psCollision.enableDynamicColliders = false; //psCollision.lifetimeLoss = new ParticleSystem.MinMaxCurve(1f); }
void StopEmission(GameObject particle) { var systems = particle.GetComponentsInChildren <ParticleSystem>(); fireExplosion.transform.SetParent(GameController.instance.gameObject.transform); fireball.transform.SetParent(GameController.instance.gameObject.transform); foreach (ParticleSystem system in systems) { ParticleSystem.CollisionModule cm = system.collision; cm.enabled = true; system.Stop(); } }
void Start() { //Debug.Log(LayerMask.GetMask("Allies")); nextFire = Time.time; //flash = GetComponent<Light>(); GetComponent <ParticleSystem>().startSize = bulletScale; if (isEnemy) { ParticleSystem temp = GetComponent <ParticleSystem>(); ParticleSystem.CollisionModule temp2 = temp.collision; temp2.collidesWith = 256; } //GetComponent<ParticleSystem>().shape = inaccuracy; }