private void Awake() { decalRoot = transform; particleSystem = gameObject.AddComponent <ParticleSystem>(); particleSystem.loop = false; particleSystem.playOnAwake = false; particleSystem.enableEmission = false; particleSystem.simulationSpace = ParticleSystemSimulationSpace.World; ParticleSystem.ShapeModule shape = particleSystem.shape; shape.enabled = false; ParticleSystemRenderer renderer = decalRoot.GetComponent <ParticleSystemRenderer>(); renderer.renderMode = ParticleSystemRenderMode.Mesh; renderer.alignment = ParticleSystemRenderSpace.World; // renderer.sortMode = ParticleSystemSortMode.YoungestInFront; renderer.enableGPUInstancing = true; renderer.castShadows = false; renderer.receiveShadows = false; renderer.material = Resources.Load <Material>("Materials/ParticleDecalMaterial"); renderer.mesh = PrimitiveHelper.GetPrimitiveMesh(PrimitiveType.Quad); for (int i = 0; i < CAPACITY; i++) { data[i] = new ParticleDecalData(); } }
private void Start() { targetCamera = GetComponentInParent <Camera>(); if (targetCamera == null) { Log.LogError(this, $"O_o\t Error: Can't find camera in parent, please add one"); } partSys = base.transform.GetComponentInChildren <ParticleSystem>(); if (partSys == null) { Log.LogError(this, $"O_o\t Error: Can't find particle system in children, please add one"); } else { partSysShape = partSys.shape; } partSysCollider = base.transform.GetComponentInChildren <BoxCollider>(); if (partSysCollider == null) { Log.LogError(this, $"O_o\t Error: Can't find BoxCollider in children, please add one"); } if (EffectPercentAdjustment == Vector3.zero) { EffectPercentAdjustment = Vector3.one; } if (ColliderPercentAdjustment == Vector3.zero) { ColliderPercentAdjustment = Vector3.one; } if (targetCamera != null && partSys != null && partSysCollider != null) { ResizeTarget(); } }
void FixedUpdate() { //if a speed isnt already stored, the change is great enough, the new value isnt faster than max speed, and reinstating speed would actually give you speed back if (!isTimerOn && rb.velocity.magnitude < ignoreReinstateIfFaster && rb.velocity.magnitude < savedVelocity.magnitude && Mathf.Abs(rb.velocity.magnitude - savedVelocity.magnitude) > magnitudeChangeThreshold) { if (savedVelocity.magnitude > maxReinstateMagnitude) { savedVelocity = savedVelocity.normalized * maxReinstateMagnitude; } reinstateVelocity = savedVelocity; timer = Instantiate(TimerPrefab).GetComponent <TimerAnimationController>(); ParticleSystem particles = timer.GetComponent <ParticleSystem>(); ParticleSystem.ShapeModule s = particles.shape; Vector3 velo = reinstateVelocity.Value; var main = particles.main; main.startSpeed = new ParticleSystem.MinMaxCurve(reinstateVelocity.Value.magnitude / 5); float angleToUse = Mathf.Atan2(velo.y, velo.x) * Mathf.Rad2Deg; angleToUse = (angleToUse - 90 < 0) ? angleToUse - 90 + 360 : angleToUse - 90;//unity plz s.rotation = new Vector3(0, 0, angleToUse); timer.ClipLength = timerLength; timer.ToFollow = transform; timer.OnTimerEnd += () => { //rb.velocity = reinstateVelocity.Value; reinstateVelocity = null; isTimerOn = false; }; timer.color = timerColor; isTimerOn = true; } savedVelocity = rb.velocity; }
void OnCollisionEnter2D(Collision2D other) { // Is it an enemy bullet? if (this.gameObject.tag == "Enemy") { // Hit Player if (other.gameObject.tag == "Player") { other.gameObject.GetComponent <damagable>().takeDamage(bulletDamage); } } else { // Hit Enemy if (other.gameObject.tag == "Enemy") { other.gameObject.GetComponent <EnemyHealth>().takeDamage(bulletDamage); } } // bullet impact effect GameObject impact = Instantiate(impactEffect, transform.position, transform.rotation); // change impact based on bullet size ParticleSystem.ShapeModule impactShape = impactEffect.GetComponent <ParticleSystem>().shape; impactShape.radius = size / 10; impactShape.length = size / 10; //impactShape.radiusSpeed = 1 - size; //destroy bullet Destroy(impact, 2f); Destroy(gameObject); }
// 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; }
// Use this for initialization void Start() { particle = GetComponent <ParticleSystem>(); circleCollider = GetComponent <CircleCollider2D>(); Server_watcher.Singleton.onClientReady.Add(OnClientReady); if (!customFire) { ParticleSystem.EmissionModule particleEmit = particle.emission; ParticleSystem.ShapeModule particleShape = particle.shape; particleShape.radius = 1.5f * size / 64; particleEmit.rateOverTime = 250 * size / 64; circleCollider.radius = 1.25f * size / 64; } if (!isServer || thermal <= 0) { Destroy(circleCollider); } else if (Server_watcher.Singleton.local_player != null) { hitFilter = Physics2D.GetLayerCollisionMask(Server_watcher.Singleton.local_player.gameObject.layer); } }
public override void Play() { CancelInvoke(); foreach (EffectParticleChild p in childs) { if (p == null) { Debug.LogError(this.name + " have an EffectParticleChild that has been destroyed! (this could happen if a effectParticle component has been added to one of the childs)"); continue; } ParticleSystem.ShapeModule shapeModule = p.particleSystem.shape; if (shapeModule.shapeType == ParticleSystemShapeType.SkinnedMeshRenderer && shapeModule.skinnedMeshRenderer == null) { shapeModule.enabled = false; } else if (shapeModule.shapeType == ParticleSystemShapeType.MeshRenderer && shapeModule.meshRenderer == null) { shapeModule.enabled = false; } else if (shapeModule.shapeType == ParticleSystemShapeType.Mesh && shapeModule.mesh == null) { shapeModule.enabled = false; } } rootParticleSystem.Play(true); if (step == Step.Start || step == Step.End) { Invoke("Despawn", lifeTime); } playTime = Time.time; }
private int GetRadiusMode(ParticleSystem.ShapeModule shape) { int res = 1; switch (shape.radiusMode) { case ParticleSystemShapeMultiModeValue.Random: res = 1; break; case ParticleSystemShapeMultiModeValue.Loop: res = 2; break; case ParticleSystemShapeMultiModeValue.PingPong: res = 3; break; case ParticleSystemShapeMultiModeValue.BurstSpread: res = 4; break; default: break; } return(res); }
private JSONObject ParseConeShape(ParticleSystem.ShapeModule shape) { JSONObject res = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); res.AddField("type", "ParticleConeShape"); res.AddField("data", data); data.AddField("angle", shape.angle); data.AddField("radius", shape.radius); data.AddField("arc", shape.arc); #if UNITY_2017_1_OR_NEWER data.AddField("arcMode", GetArcMode(shape)); data.AddField("arcSpread", shape.arcSpread); data.AddField("radiusThickness", shape.radiusThickness); data.AddField("position", GetVect3(shape.position)); data.AddField("rotation", GetVect3(shape.rotation)); data.AddField("scale", GetVect3(shape.scale)); #endif data.AddField("length", shape.length); int emitfrom = 1; if (shape.shapeType == ParticleSystemShapeType.ConeVolume) { emitfrom = 2; } else if (shape.shapeType == ParticleSystemShapeType.ConeVolumeShell) { emitfrom = 3; data.AddField("radiusThickness", 0); } data.AddField("emitFrom", emitfrom); return(res); }
private JSONObject ParseBox(ParticleSystem.ShapeModule shape) { JSONObject res = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); res.AddField("type", "ParticleBoxShape"); res.AddField("data", data); int from = 1; if (shape.shapeType == ParticleSystemShapeType.BoxEdge) { from = 3; } if (shape.shapeType == ParticleSystemShapeType.BoxShell) { from = 2; } data.AddField("emitFrom", from); #if UNITY_2017_1_OR_NEWER data.AddField("boxThickness", GetVect3(shape.boxThickness)); data.AddField("position", GetVect3(shape.position)); data.AddField("rotation", GetVect3(shape.rotation)); data.AddField("scale", GetVect3(shape.scale)); #else data.AddField("scale", GetVect3(shape.box)); #endif return(res); }
private JSONObject ParseHemisphere(ParticleSystem.ShapeModule shape) { JSONObject res = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.OBJECT); res.AddField("type", "ParticleHemiSphereShape"); res.AddField("data", data); data.AddField("radius", shape.radius); data.AddField("arc", shape.arc); int radiusThickness = 1; if (shape.shapeType == ParticleSystemShapeType.HemisphereShell) { radiusThickness = 0; } data.AddField("radiusThickness", radiusThickness); #if UNITY_2017_1_OR_NEWER data.AddField("radiusThickness", shape.radiusThickness); data.AddField("arcMode", GetArcMode(shape)); data.AddField("arcSpread", shape.arcSpread); data.AddField("position", GetVect3(shape.position)); data.AddField("rotation", GetVect3(shape.rotation)); data.AddField("scale", GetVect3(shape.scale)); #endif return(res); }
// Update is called once per frame void Update() { // figure out current location and angle Vector3 beamDir = !useReflection ? (Quaternion.Euler(angleOffset) * lightSource.transform.up).normalized : reflectionAngle; Vector3 firstPoint = lightSource.transform.position; //might get rid of this Vector3, just get it from lineRenderer float cutoffDist = beamLength; // check collisions with all obstacles List <Obstacle> collisionList = new List <Obstacle>(); List <float> distList = new List <float> (); for (int i = 0; i < Obstacle.obstacleList.Count; i++) { if (Obstacle.obstacleList [i] == this) { continue; } Vector3 obsVec = Obstacle.obstacleList [i].transform.position - firstPoint; float dotProduct = Vector3.Dot(obsVec, beamDir); if (dotProduct > 0) { Vector3 lineProj = firstPoint + dotProduct * beamDir; float distFromBeam = (lineProj - Obstacle.obstacleList [i].transform.position).magnitude; if (distFromBeam <= beamWidth && obsVec.magnitude <= cutoffDist) //later, add in obstacle radius as well { // it's a hit! add it to the list collisionList.Add(Obstacle.obstacleList [i]); distList.Add(obsVec.magnitude); if (Obstacle.obstacleList [i].blockLight) { cutoffDist = obsVec.magnitude; } } } } for (int i = 0; i < collisionList.Count; i++) { if (distList [i] <= cutoffDist) { collisionList[i].HitByLight(firstPoint, lightSource.transform.position + beamDir * cutoffDist); } } Vector3[] beamPositions = new Vector3[30]; for (int i = 0; i < beamPositions.Length; i++) { beamPositions[i] = lightSource.transform.position + beamDir * cutoffDist * ((float)i / beamPositions.Length); } lightBeam.positionCount = beamPositions.Length; lightBeam.SetPositions(beamPositions); if (partSys) { partSys.transform.position = lightSource.transform.position + beamDir * cutoffDist / 2f; ParticleSystem.ShapeModule shapeMod = partSys.shape; shapeMod.scale = new Vector3(cutoffDist / 2f, 1f, beamWidth / 2f); } }
private void HandleFootstepVfx(FootstepFX selectedFootstepVfx) { if (selectedFootstepVfx == FootstepFX.Leaves && !_leaves.isEmitting) { ParticleSystem.EmissionModule leavesPsEmission = _leaves.emission; ParticleSystem.ShapeModule leavesPsShape = _leaves.shape; ParticleSystem.MainModule main = _leaves.main; float absoluteVelocity = Mathf.Abs(_velocity.x); // Change leaves amount depending on player velocity leavesPsEmission.rateOverTime = absoluteVelocity < speed ? 10 : absoluteVelocity.Remap(speed, 24, 10, 20); // Change leaves rotation emitter depending on player velocity float leavesPsComputedRotationY = absoluteVelocity < speed ? 0 : absoluteVelocity.Remap(speed, 24, 0, 70); leavesPsShape.rotation = new Vector3(0f, leavesPsComputedRotationY * Mathf.Sign(_velocity.x), 0f); // Change leaves speed depending on player velocity main.startSpeed = absoluteVelocity < speed ? 0 : absoluteVelocity.Remap(speed, 24, 3, 6); _leaves.Play(); } else if (selectedFootstepVfx == FootstepFX.Dust && !_dustPS.isEmitting) { ParticleSystem.ShapeModule dustPsShape = _dustPS.shape; dustPsShape.rotation = new Vector3(0f, Mathf.Sign(_velocity.x) * -70, 0f); _dustPS.Play(); } }
void SetOutline(GameObject target)//move particles to target { try { if (!target.Equals(outline.transform.parent.gameObject)) { outline.Clear(); } } catch { } ParticleSystem.ShapeModule shape = outline.shape; //MeshFilter filter = target.GetComponent<MeshFilter>(); //shape.mesh = filter.mesh; OutlineRadius rad = target.GetComponent <OutlineRadius>(); if (rad != null) { shape.radius = rad.radius; } else { shape.radius = 1; } outline.transform.SetParent(target.transform); outline.transform.localPosition = Vector3.zero; outline.transform.localEulerAngles = Vector3.zero; outline.Play(); }
void Start() { audioSources = GetComponents <AudioSource> (); // Initialising variables for fireParticles fireShapeModule = fireParticles.shape; // Shape originalFireParticleBounds = fireParticles.shape.box; fireMainModule = fireParticles.main; // Start Size fireStartSize.y = fireParticles.main.startSize.constant; fireEmissionModule = fireParticles.emission; // Emission Rate fireEmissions.y = fireParticles.emission.rateOverTime.constant; fireEmissions.x = Mathf.Floor(fireEmissions.y * 0.3f); // Initialising variables for smokeParticles //smokeMainModule = smokeParticles.main; // Start Life Time //smokeStartLifeTime.y = smokeMainModule.startLifetime.constant; //smokeStartSize.y = smokeMainModule.startSize.constant; // Start Size //smokeEmissionModule = smokeParticles.emission; // Emission Rate //smokeEmissions.y = smokeEmissionModule.rateOverTime.constant; // Initialising variables for emberParticles emberEmissionModule = embersParticles.emission; // Emission Rate emberEmissions.y = emberEmissionModule.rateOverTime.constant; }
// Start is called before the first frame update private void Start() { _guid = gameObject.GetInstanceID(); _buoys = new Transform[transform.childCount]; _mesh = new Mesh(); var triangles = new int[_buoys.Length * 3]; _vertices = new Vector3[_buoys.Length]; _samplePoints = new NativeArray <float3>(_buoys.Length, Allocator.Persistent); _heights = new float3[_buoys.Length]; _normals = new float3[_buoys.Length]; for (var i = 0; i < _buoys.Length; i++) { _buoys[i] = transform.GetChild(i); _samplePoints[i] = _buoys[i].position; _vertices[i] = _samplePoints[i]; triangles[3 * i] = i; triangles[3 * i + 1] = (int)Mathf.Repeat(i + 1, _buoys.Length); triangles[3 * i + 2] = (int)Mathf.Repeat(i + 2, _buoys.Length); } _mesh.vertices = _vertices; _mesh.triangles = triangles; if (ps) { _particleShape = ps.shape; _particleShape.mesh = _mesh; } }
public void InitPS() { SceneBaseManager sceneBaseManager = GameScenesHandler.Instance.manager.GetSceneManager <SceneBaseManager>(); ParticleSystem.ShapeModule shapeModule = psFog.shape; shapeModule.scale = sceneBaseManager.scaleRangeForFog; }
void ParticleSetup() { particles = gameObject.AddComponent <ParticleSystem>(); particleRenderer = gameObject.GetComponent <ParticleSystemRenderer>(); GameObject defaultParticle = GameObject.Find("DefaultParticle"); if (defaultParticle) { particleRenderer.material = defaultParticle.GetComponent <MeshRenderer>().material; } else { Debug.LogError("Default particle sprite not found"); particleRenderer.material = new Material(Shader.Find("Particles/Additive")); } ParticleSystem.EmissionModule emmission = particles.emission; emmission.rateOverTimeMultiplier = 5f; shape = particles.shape; shape.scale = Vector3.one * 0.2f; ParticleSystem.MainModule main = particles.main; main.startLifetime = 1; }
public override void SetRenderer(Renderer renderer, bool secondary) { if (renderer == null) { return; } foreach (EffectParticleChild p in childs) { ParticleSystem.ShapeModule shapeModule = p.particleSystem.shape; if ((p.useRenderer == EffectTarget.Main && !secondary) || (p.useRenderer == EffectTarget.Secondary && secondary)) { if (renderer is MeshRenderer) { shapeModule.shapeType = ParticleSystemShapeType.MeshRenderer; shapeModule.meshRenderer = renderer as MeshRenderer; shapeModule.enabled = true; } if (renderer is SkinnedMeshRenderer) { shapeModule.shapeType = ParticleSystemShapeType.SkinnedMeshRenderer; shapeModule.skinnedMeshRenderer = renderer as SkinnedMeshRenderer; shapeModule.enabled = true; } } } }
private IEnumerator ClaimingRewardAnimation() { int playerCoins = SceneActivationBehaviour <GameLogicActivator> .Instance.GameController.Player.Coins; SceneActivationBehaviour <UICoinCounterActivator> .Instance.CoinCounterClaim(playerCoins, coinRewardCount, 0.2f); //TODO: change angle of emission to point at coin counter GameObject coinTarget = SceneActivationBehaviour <UICoinCounterActivator> .Instance.CoinObject; Vector3 target = canvasCamera.WorldToScreenPoint(coinTarget.transform.position); Vector3 start = canvasCamera.WorldToScreenPoint(coinFX.transform.position); Vector3 diff = target - start; float particleAngle = 90.0f - (float)((180.0f / Math.PI) * Math.Atan(diff.y / diff.x)); ParticleSystem.ShapeModule particleShape = coinFX.shape; particleShape.rotation = new Vector3(0, particleAngle, 0); coinFX.gameObject.SetActive(true); yield return(delay); coinFX.gameObject.SetActive(false); popupWindow.SetActive(false); CleanUpAction(); }
public override GameObject Throw(Vector3 position, Vector3 direccion, SkillHandler handler, int owner, int team) { Vector3 pos = new Vector3(); if (m_directionOffset) { pos = new Vector3(position.x + direccion.x * m_positionOffset.x, m_positionOffset.y, position.z + direccion.z * m_positionOffset.z); } else { pos = new Vector3(position.x, m_positionOffset.y, position.z); } GameObject go = Instantiate(this.gameObject, pos, this.transform.rotation); go.GetComponent <LightSkill2>().m_handler = handler; go.GetComponent <LightSkill2>().m_direccion = direccion; go.GetComponent <LightSkill2>().m_skillId = Random.Range(0, 10000); go.GetComponent <LightSkill2>().m_owner = owner; go.GetComponent <LightSkill2>().m_team = team; handler.gameObject.GetComponentInChildren <Animator>().SetTrigger("attack"); if (handler.GetComponent <BuffLightSkill3>() != null) { go.GetComponent <LightSkill2>().m_particle.startSize *= m_lightMultiplier; go.GetComponent <LightSkill2>().m_particle.transform.GetChild(0).GetComponent <ParticleSystem>().startSize *= m_lightMultiplier; ParticleSystem.ShapeModule shapeModule = go.GetComponent <LightSkill2>().m_particle.transform.GetChild(0).GetComponent <ParticleSystem>().shape; shapeModule.radius *= m_lightMultiplier; go.GetComponent <LightSkill2>().m_particle.transform.GetChild(1).GetComponent <ParticleSystem>().startSize *= m_lightMultiplier; shapeModule = go.GetComponent <LightSkill2>().m_particle.transform.GetChild(1).GetComponent <ParticleSystem>().shape; shapeModule.radius *= m_lightMultiplier; go.GetComponent <LightSkill2>().m_multiplier *= m_lightMultiplier; } return(go); }
private void PlayParticle(Vector3 position, Vector3 direction) { m_particleSystem = Particle.GetComponent <ParticleSystem>(); ParticleSystem.ShapeModule _editableShape = m_particleSystem.shape; _editableShape.position = position; transform.position = direction; }
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); } }
// Update is called once per frame /*void Update() * { * for (int i = 0; i < m_Columns.Length; ++i) * { * //float ratio = ((float)i) / m_columns.Length; * * float leftDelta = 0; * if (i > 0) * leftDelta = neighbourTransfer * (m_Columns[i - 1].currentHeight - m_Columns[i].currentHeight); * * float rightDelta = 0; * if (i < m_Columns.Length - 1) * rightDelta = neighbourTransfer * (m_Columns[i + 1].currentHeight - m_Columns[i].currentHeight); * * float force = leftDelta; * force += rightDelta; * force += tension * (m_Columns[i].baseHeight - m_Columns[i].currentHeight); * * m_Columns[i].velocity = dampening * m_Columns[i].velocity + force; * * m_Columns[i].currentHeight += m_Columns[i].velocity; * } * * for (int i = 0; i < m_Columns.Length; ++i) * { * meshVertices[m_Columns[i].vertexIndex].y = m_Columns[i].currentHeight; * } * * m_Mesh.vertices = meshVertices; * * m_Mesh.UploadMeshData(false); * }*/ public void AdjustComponentSizes() { ParticleSystem.ShapeModule steamShape = m_Steam.shape; steamShape.radius = size.x * 0.5f; Vector3 steamLocalPosition = m_Steam.transform.localPosition; steamLocalPosition = offset + Vector2.up * size.y * 0.5f; m_Steam.transform.localPosition = steamLocalPosition; ParticleSystem.ShapeModule bubblesShape = m_Bubbles.shape; bubblesShape.radius = size.x * 0.5f; Vector3 bubblesLocalPosition = m_Bubbles.transform.localPosition; bubblesLocalPosition = offset + Vector2.down * size.y * 0.5f; m_Bubbles.transform.localPosition = bubblesLocalPosition; #if UNITY_EDITOR if (Application.isPlaying) { //we don't want to do it in editor when not playing as it would leak object #endif m_Steam.Simulate(0.1f); m_Bubbles.Simulate(0.1f); #if UNITY_EDITOR } #endif m_BoxCollider.size = size; m_BoxCollider.offset = offset; m_BuoyancyEffector.surfaceLevel = size.y * 0.5f - 0.84f; }
public override void OnEvent(FusRoDaFBEvent evnt) { //Switch mode ParticleSystem frdParticleSystem = Instantiate(this.fusRoDaFeedback, this.startPointFus.position, evnt.Rotation); ParticleSystem.ShapeModule shape = frdParticleSystem.shape; Destroy(frdParticleSystem.gameObject, 1.2f); ParticleSystem.MainModule main = frdParticleSystem.main; main.startColor = state.MyColor; main = frdParticleSystem.GetComponent <ParticleSystem>().main; main.startColor = state.MyColor; switch (mode) { case FusRoDaMode.Cone: shape.length = this.distanceCheck; shape.angle = this.angleMaxToCheckCone; break; case FusRoDaMode.Laser: shape.length = this.distanceCheck; shape.angle = 0f; shape.radius = this.fusDetectionRadius; main.startSize = this.fusDetectionRadius; break; } }
// Update is called once per frame void Update() { if (HasClothes() && !wereBeesClothedLastFrame) { beesClothed.SetActive(true); beesUnclothed.SetActive(false); wereBeesClothedLastFrame = true; } else if (!HasClothes() && wereBeesClothedLastFrame) { beesClothed.SetActive(false); beesUnclothed.SetActive(true); wereBeesClothedLastFrame = false; } if (!HasClothes()) { foreach (ParticleSystem particle in particles) { ParticleSystem.EmissionModule emission = particle.emission; emission.rateOverTime = ((float)numBees / 1000f) * 100f; ParticleSystem.ShapeModule shape = particle.shape; shape.radius = ((float)numBees / 1000f) * 1.5f; } } if (numBees < 100) { Destroy(this.gameObject); } }
// Update is called once per frame void Update() { if (forcedMove) { return; } Vector3 velocityVector = movement.selfBody.velocity; float speedModifier = velocityVector.magnitude / movement.walkVelocity * bobModifier; float bobbingModifier = speedModifier * (movement.isGrounded ? 1 : 0); float swayingModifier = Mathf.Abs(velocityVector.x) / Mathf.Max(velocityVector.magnitude, 1); animator.SetFloat("SpeedModifier", speedModifier); animator.SetFloat("BobbingModifier", bobbingModifier); animator.SetBool("Sway", movement.isGrounded && Mathf.Abs(velocityVector.x) / velocityVector.magnitude > 0.4f && velocityVector.sqrMagnitude > 0.1f); animator.SetFloat("xDirection", velocityVector.x); float zAngle = Mathf.Atan2(velocityVector.z, velocityVector.x) * Mathf.Rad2Deg; ParticleSystem.ShapeModule dashPartShape = dashParticleSystem.shape; dashPartShape.rotation = Vector3.right * 90 + Vector3.forward * (zAngle + 90); ParticleSystem.EmissionModule dashPartEmission = dashParticleSystem.emission; dashPartEmission.rateOverTimeMultiplier = bobbingModifier * emitSpeed; if (movement.isGrounded) { if (movement.enabled && Controls.jumpInputDown() && !movement.forcedMove) { poofParticleSystem.Play(); } } }
void onDead() { Vector2 pv = -m_rigidbody2D.velocity; // 获取速度的反方向 m_rigidbody2D.velocity = new Vector2(0, 0); // 重置主角的速度 // 兼容速度为0的情况 if (pv.magnitude == 0) { pv = m_direction == Direction.Right ? new Vector2(0, -1) : new Vector2(0, 1); } // 播放粒子效果 ParticleSystem.ShapeModule shape = m_sprayParticle.shape; Vector3 shapeRot = shape.rotation; float angle = Vector2.Angle(pv, new Vector2(0, 1)); if (pv.x < 0) { angle = -angle; } shapeRot.y = angle; shape.rotation = shapeRot; m_sprayParticle.GetComponent <Transform>().position = this.transform.position; m_sprayParticle.Play(); // 隐藏主角 this.gameObject.SetActive(false); this.transform.position = new Vector3(0, 0, 0); // 播放音效 AudioClip clip = Resources.Load <AudioClip>("Sounds/DeadElectricity"); AudioSource.PlayClipAtPoint(clip, Vector3.zero); }
private Param param; // 設定パラメータ //------------------------------------------------------------------------------------------ // Awake //------------------------------------------------------------------------------------------ private void Awake() { // モジュールを取得する system = GetComponent <ParticleSystem>(); mainModule = system.main; shapeModule = system.shape; }
private void SpawnImpactParticles(Vector3 position, Vector2 dimensions) { iImpactParticleEffect = Instantiate(impactParticleEffect, position, Quaternion.identity); ParticleSystem.ShapeModule ps = iImpactParticleEffect.GetComponent <ParticleSystem>().shape; ps.scale = new Vector3(dimensions.x, 1, 1); Destroy(iImpactParticleEffect, 1.0f); }