void Awake() { myTransform = GetComponent<Transform>(); myRigidBody = GetComponent<Rigidbody>(); myHealth = GetComponent<Health>(); BloodParticle = GetComponentInChildren<ParticleSystem>(); }
// Use this for initialization protected override void Awake() { base.Awake(); vfx = GetComponent<ParticleSystem>(); coll = GetComponent<PolygonCollider2D>(); effector = GetComponent<PointEffector2D>(); }
void Start() { soundStopped = true; trigger = GetComponent<Trigger>(); particles = GetComponent<ParticleSystem>(); }
// Use this for initialization void Start() { owner = GetComponentInParent<Character>(); playerHit = Resources.Load<ParticleSystem>("Particles/Prefabs/OnHit/FX_BloodHit_Player"); enemyHit = Resources.Load<ParticleSystem>("Particles/Prefabs/OnHit/FX_BloodHit_EnemySlow"); envHit = Resources.Load<ParticleSystem>("Particles/Prefabs/OnHit/FX_EnvHit"); }
// Start void Start() { myParticleSystem = particleSystem; // Server side doesn't compute particles if(uLink.Network.isServer) { // Disable emission myParticleSystem.enableEmission = false; if(!myParticleSystem.isStopped) myParticleSystem.Stop(); // Is there a delayed explosion component? var delayedExplosion = GetComponent<DelayedExplosion>(); // Destroy this object after the standard duration of the particle system if(delayedExplosion == null) Destroy(gameObject, myParticleSystem.duration); else Destroy(gameObject, delayedExplosion.delayTime + 0.1f); // No LateUpdate on the server enabled = false; } }
private void Awake() { m_ExplosionParticles = Instantiate(m_ExplosionPrefab).GetComponent<ParticleSystem>(); m_ExplosionAudio = m_ExplosionParticles.GetComponent<AudioSource>(); m_ExplosionParticles.gameObject.SetActive(false); }
void Awake() { rb2d = GetComponent<Rigidbody2D>(); anim = GetComponent<Animator>(); aud = GetComponent<AudioSource>(); jps = transform.GetChild(2).GetComponent<ParticleSystem>(); }
// Use this for initialization void Start() { //Hämtar bara referenser 1 gång, GetComponent är väldigt långsam!!! rb2d = GetComponent<Rigidbody2D>(); anim = GetComponent<Animator>(); ps = GetComponent<ParticleSystem>(); }
public override void AffectParticle(ref ParticleSystem.Particle p, float dt) { // This math is much easier in local space if (particleController.IsWorldSpace()) { particleController.InverseTransformParticle(ref p); } Vector3 r = p.position - centerOffset; float radius = r.magnitude; Vector3 ac = Vector3.Cross(up, r.normalized); ac.Normalize(); if (acceleration) { ac *= linearTangentalAcceleration * dt; Vector3 cf = ((r * ac.sqrMagnitude) / radius) * centrifugalCoef; p.velocity += ac + cf; } else { ac *= linearTangentalAcceleration; p.velocity = ac; } if (particleController.IsWorldSpace()) { particleController.TransformParticle(ref p); } }
void Awake() { _particles = this.particleSystem; _particles.renderer.sortingLayerName = "Foreground"; _mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>(); _trackerScript = _mainCamera.GetComponent<CameraTracker> (); }
public override ParticleAffector CreateAffector( ParticleSystem psys ) { ParticleAffector p = new LinearForceAffector( psys ); affectorList.Add( p ); return p; }
void OnEnable() { _particleSystem = GetComponent<ParticleSystem>(); StopAllCoroutines(); StartCoroutine("ParticleProcess"); }
private void Set_SmallSteam() { _pSmall.SetActive (true) ; _pMedium.SetActive (false) ; _p = _pSmall.GetComponent<ParticleSystem>() ; _p.enableEmission = false ; }
public override void AffectParticles( ParticleSystem system, float timeElapsed ) { Vector3 scaledVector = Vector3.Zero; if ( forceApp == ForceApplication.Add ) { // scale force by time scaledVector = forceVector * timeElapsed; } // affect each particle for ( int i = 0; i < system.Particles.Count; i++ ) { Particle p = (Particle)system.Particles[ i ]; if ( forceApp == ForceApplication.Add ) { p.Direction += scaledVector; } else { // Average p.Direction = ( p.Direction + forceVector ) / 2; } } }
void OnEnable() { m_ps = transform.Find("ef death").GetComponent<ParticleSystem>(); Vector3 pos = m_ps.transform.position; pos.y = 0f; m_ps.transform.position = pos; }
void Awake () { capsuleCollider = GetComponent <CapsuleCollider> (); currentHealth = startingHealth; hitParticles = GetComponentInChildren <ParticleSystem> (); animator = GetComponent<Animator> (); }
// Use this for initialization void Start() { ps = this.GetComponent<ParticleSystem> (); statText.text = stat; statText.transform.position = this.transform.position;//textPos.transform.position;// + new Vector3(0.5f, 0.0f, 0.0f); statText.enabled = false; }
// Use this for initialization public void Awake() { ParticleSystem = GetComponentInChildren<ParticleSystem>(); _emissionModule = ParticleSystem.emission; ResetThis(); ParticleSystem.gameObject.SetActive(false); }
private ParticleSystem instantiate(ParticleSystem prefab, Vector3 position) { Vector3 wek = new Vector3 (position.x, position.y + 1, position.z - 1); ParticleSystem newParticleSystem = Instantiate(prefab,wek,Quaternion.identity) as ParticleSystem; Destroy(newParticleSystem.gameObject,newParticleSystem.startLifetime); return newParticleSystem; }
/// <summary> /// Initialises the script /// </summary> void Start() { m_particles = GetComponent<ParticleSystem> (); m_particles.GetComponent<Renderer>().sortingLayerName = "World"; m_particles.GetComponent<Renderer>().sortingOrder = 4; m_rigidBody = transform.parent.GetComponent<Rigidbody>(); }
void Start() { controller = new Controller (); controller.EnableGesture (Gesture.GestureType.TYPE_SWIPE); controller.EnableGesture (Gesture.GestureType.TYPE_CIRCLE); controller.EnableGesture (Gesture.GestureType.TYPE_SCREEN_TAP); //for swipe controller.Config.SetFloat ("Gesture.Swipe.MinLength", 200.0f); controller.Config.SetFloat ("Gesture.Swipe.MinVelocity", 750f); //for circle controller.Config.SetFloat ("Gesture.Circle.MinRadius", 80.0f); controller.Config.SetFloat ("Gesture.Circle.MinArc", 1.8f); //for screen tap controller.Config.SetFloat ("Gesture.ScreenTap.MinForwardVelocity", 1.0f); controller.Config.SetFloat ("Gesture.ScreenTap.HistorySeconds", .05f); controller.Config.SetFloat ("Gesture.ScreenTap.MinDistance", 1.0f); controller.Config.Save (); timeLimit = 5.0f; timer = 0.0f; p = GameObject.Find ("ps").GetComponent<ParticleSystem> (); before = GameObject.Find ("before").GetComponent<SpriteRenderer> (); after = GameObject.Find ("after").GetComponent<SpriteRenderer> (); after.color = new Color (255, 255, 255, 0); p.Pause (); }
void Start() { stateController = GameObject.FindWithTag("Player").GetComponent<TurtleStateController>(); forceVector = transform.forward * magnitude; particleSystem = GetComponent<ParticleSystem>(); particleSystem.Play(); }
void PuffGroundFX_End() { if (PuffGroundParticleSystem != null) { PuffGroundParticleSystem.loop = false; PuffGroundParticleSystem = null; } }
void Awake() { Instance = this; hearts = transform.FindChild("HeartParticles").GetComponent<ParticleSystem>(); rb = GetComponent<Rigidbody2D>(); animator = GetComponent<Animator>(); }
void Start() { characterController = GetComponent<CharacterController>(); characterParticles = GameObject.Find("Player/Flute Radius").GetComponent<ParticleSystem>(); fluteCall1 = FMOD_StudioSystem.instance.GetEvent("event:/sfx/player/flute1"); fluteCall2 = FMOD_StudioSystem.instance.GetEvent("event:/sfx/player/flute2"); }
// Use this for initialization void Start() { tx = transform; starDistanceSqr = starDistance * starDistance; starClipDistanceSqr = starClipDistance * starClipDistance; particleSystem = GetComponent<ParticleSystem> (); }
// Update is called once per frame void Update () { if (Input.GetMouseButtonDown (0)) { clone = Instantiate (shotEffectPrefab, transform.position, transform.rotation) as ParticleSystem; clone.Play (); } }
protected void Start() { particleComponent = GetComponent<ParticleSystem>(); particleEmission = particleComponent.emissionRate; particleComponent.emissionRate = TOD_Sky.Instance.IsDay ? particleEmission : 0; }
void Awake() { m_time = 0f; m_isFireing = false; m_particleSystem = GetComponent<ParticleSystem>(); m_lineRenderer = GetComponent<LineRenderer>(); }
//private GameObject streamRight; //private GameObject streamCentre; //private ParticleSystem streamLeftP; //private ParticleSystem streamRightP; //private ParticleSystem streamCentreP; void Start() { instance = this; anim = GameObject.Find ("Portal_").GetComponent<Animator> (); text = GameObject.Find ("Text"); textEnter = GameObject.Find ("Text_Enter"); transition = GameObject.Find ("TransitionTemp").GetComponent<Animator>(); galaxy1 = GameObject.Find ("Galaxy1").GetComponent<ParticleSystem>(); galaxy1_1 = GameObject.Find ("Galaxy1_1").GetComponent<ParticleSystem>(); galaxy1_1_1 = GameObject.Find ("Galaxy1_1_1").GetComponent<ParticleSystem>(); galaxy1_2 = GameObject.Find ("Galaxy1_2").GetComponent<ParticleSystem>(); galaxy1_3 = GameObject.Find ("Galaxy1_3").GetComponent<ParticleSystem>(); galaxy2 = GameObject.Find ("Galaxy2").GetComponent<ParticleSystem>(); galaxy2_1 = GameObject.Find ("Galaxy2_1").GetComponent<ParticleSystem>(); galaxy2_1_1 = GameObject.Find ("Galaxy2_1_1").GetComponent<ParticleSystem>(); galaxy2_2 = GameObject.Find ("Galaxy2_2").GetComponent<ParticleSystem>(); galaxy2_3 = GameObject.Find ("Galaxy2_3").GetComponent<ParticleSystem>(); galaxy3 = GameObject.Find ("Galaxy3").GetComponent<ParticleSystem>(); galaxy3_1 = GameObject.Find ("Galaxy3_1").GetComponent<ParticleSystem>(); galaxy3_1_1 = GameObject.Find ("Galaxy3_1_1").GetComponent<ParticleSystem>(); galaxy3_2 = GameObject.Find ("Galaxy3_2").GetComponent<ParticleSystem>(); galaxy3_3 = GameObject.Find ("Galaxy3_3").GetComponent<ParticleSystem>(); //streamRightP = GameObject.Find ("StreamRight").GetComponent<ParticleSystem>(); //streamCentreP = GameObject.Find ("StreamCentre").GetComponent<ParticleSystem>(); //streamLeft = GameObject.Find ("StreamLeft"); //streamRight = GameObject.Find ("StreamRight"); //streamCentre = GameObject.Find ("StreamCentre"); }
private void Awake() { particleSystem = GetComponentInChildren <ParticleSystem>(); meshRenderer = gameObject.GetComponent <MeshRenderer>(); light = GetComponentInChildren <Light>(); }
private void Start() { particles = GetComponent <ParticleSystem>(); PlayerController.OnItemCarried += OnItemCarried; PlayerController.OnItemDropped += OnItemDropped; }
public void Move(float move, bool jump) { // check jump logic and see if this is a legal jump newJump = checkJumpLogic(jump); //only control the player if grounded or airControl is turned on if (Grounded || AirControl) { // Move the character by finding the target velocity Vector3 targetVelocity = new Vector2(move * 10f, rb2d.velocity.y); // And then smoothing it out and applying it to the character rb2d.velocity = Vector3.SmoothDamp(rb2d.velocity, targetVelocity, ref Velocity, MovementSmoothing); // If the input is moving the player right and the player is facing left... if (move > 0 && !FacingRight) { // ... flip the player. Flip(); } // Otherwise if the input is moving the player left and the player is facing right... else if (move < 0 && FacingRight) { // ... flip the player. Flip(); } } // Grabbing the wall if (!Grounded && GrabbableWall) { if (rb2d.velocity.y <= 0) //player must be stationary or descending { bool prevWallSlide = WallSliding; //if they are pressing towards the correct wall, slide down if (move < 0 && !FacingRight) { // ... slow down WallSliding = true; } // Otherwise if the input is moving the player left and the player is facing right... else if (move > 0 && FacingRight) { // ... slow down WallSliding = true; } //did WallSliding Just Toggle? if (prevWallSlide != WallSliding) //catch the wall for a moment { rb2d.velocity = Vector2.zero; } } else // ensure that gravity is set correctly because you are going up { WallSliding = false; } } else // neither ground nor wall are affecting you. { WallSliding = false; } // If the player should jump... if (newJump) { if (Grounded) //normal ground jump { Grounded = false; rb2d.AddForce(new Vector2(0f, JumpForce)); ParticleSystem dustInstance = Instantiate(jumpParticles, GroundCheck); } else if (IsWallKickable() && recentlyWallSlid > 0) { WallSliding = false; rb2d.AddForce(new Vector2(move * WallKickForce, WallSlideMult * JumpForce)); Debug.Log("Move: " + move.ToString() + " Force: " + (move * WallKickForce).ToString()); ParticleSystem dustInstance = Instantiate(jumpParticles, WallKickCheck); } } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("Button")) { CageObj = GameObject.FindGameObjectWithTag("Cage"); SoundManager.PlaySound("cage"); Object.Destroy(CageObj); } else if (other.gameObject.CompareTag("h1")) { if (life < 3) { heart = GameObject.FindGameObjectWithTag("h1"); life++; Object.Destroy(heart); } } else if (other.gameObject.CompareTag("h2")) { if (life < 3) { heart = GameObject.FindGameObjectWithTag("h2"); life++; Object.Destroy(heart); } } else if (other.gameObject.CompareTag("h3")) { if (life < 3) { heart = GameObject.FindGameObjectWithTag("h3"); life++; Object.Destroy(heart); } } else if (other.gameObject.CompareTag("h4")) { if (life < 3) { heart = GameObject.FindGameObjectWithTag("h4"); life++; Object.Destroy(heart); } } else if (other.gameObject.CompareTag("VictoryFish")) { Fish = GameObject.FindGameObjectWithTag("VictoryFish"); if (score >= 60) { SoundManager.PlaySound("confetti"); confetti_clone = Instantiate(confetti, Fish.transform.position, Quaternion.identity); Destroy(confetti_clone.gameObject, 2f); Invoke("next", 2f); // CHANGE TO CUTSCENE, NOT ENDGAME } else { gemtext.enabled = true; gemtext.text = "At least 60 gem points needed to continue!"; Invoke("notext", 3f); } } else if (other.gameObject.CompareTag("Gem1")) { if (alph > 0.5) { Gem = GameObject.FindGameObjectWithTag("Gem1"); gemsys_clone = Instantiate(gemsys, Gem.transform.position, Quaternion.identity); SoundManager.PlaySound("gem"); Object.Destroy(Gem); score++; scoreBoard.text = "Score: " + score; Destroy(gemsys_clone.gameObject, 2f); } } else if (other.gameObject.CompareTag("Gem2")) { if (alph > 0.5) { Gem = GameObject.FindGameObjectWithTag("Gem2"); gemsys_clone = Instantiate(gemsys, Gem.transform.position, Quaternion.identity); SoundManager.PlaySound("gem"); Object.Destroy(Gem); score++; scoreBoard.text = "Score: " + score; Destroy(gemsys_clone.gameObject, 2f); } } else if (other.gameObject.CompareTag("Gem3")) { if (alph > 0.5) { Gem = GameObject.FindGameObjectWithTag("Gem3"); gemsys_clone = Instantiate(gemsys, Gem.transform.position, Quaternion.identity); SoundManager.PlaySound("gem"); Object.Destroy(Gem); score++; scoreBoard.text = "Score: " + score; Destroy(gemsys_clone.gameObject, 2f); } } else if (other.gameObject.CompareTag("Gem4")) { if (alph > 0.5) { Gem = GameObject.FindGameObjectWithTag("Gem4"); gemsys_clone = Instantiate(gemsys, Gem.transform.position, Quaternion.identity); SoundManager.PlaySound("gem"); Object.Destroy(Gem); score++; scoreBoard.text = "Score: " + score; Destroy(gemsys_clone.gameObject, 2f); } } else if (other.gameObject.CompareTag("Gem5")) { if (alph > 0.5) { Gem = GameObject.FindGameObjectWithTag("Gem5"); gemsys_clone = Instantiate(gemsys, Gem.transform.position, Quaternion.identity); SoundManager.PlaySound("gem"); Object.Destroy(Gem); score++; scoreBoard.text = "Score: " + score; Destroy(gemsys_clone.gameObject, 2f); } } else if (other.gameObject.CompareTag("Gem10")) { if (alph > 0.5) { Gem = GameObject.FindGameObjectWithTag("Gem10"); gemsys_clone = Instantiate(gemsys, Gem.transform.position, Quaternion.identity); SoundManager.PlaySound("gem"); Object.Destroy(Gem); score = score + 5; scoreBoard.text = "Score: " + score; Destroy(gemsys_clone.gameObject, 2f); } } else if (other.gameObject.CompareTag("Gem6")) { if (alph > 0.5) { Gem = GameObject.FindGameObjectWithTag("Gem6"); gemsys_clone = Instantiate(gemsys, Gem.transform.position, Quaternion.identity); SoundManager.PlaySound("gem"); Object.Destroy(Gem); score++; scoreBoard.text = "Score: " + score; Destroy(gemsys_clone.gameObject, 2f); } } else if (other.gameObject.CompareTag("Gem7")) { if (alph > 0.5) { Gem = GameObject.FindGameObjectWithTag("Gem7"); gemsys_clone = Instantiate(gemsys, Gem.transform.position, Quaternion.identity); SoundManager.PlaySound("gem"); Object.Destroy(Gem); score = score + 10; scoreBoard.text = "Score: " + score; Destroy(gemsys_clone.gameObject, 2f); } } else if (other.gameObject.CompareTag("Gem8")) { if (alph > 0.5) { Gem = GameObject.FindGameObjectWithTag("Gem8"); gemsys_clone = Instantiate(gemsys, Gem.transform.position, Quaternion.identity); SoundManager.PlaySound("gem"); Object.Destroy(Gem); score = score + 5; scoreBoard.text = "Score: " + score; Destroy(gemsys_clone.gameObject, 2f); } } else if (other.gameObject.CompareTag("Gem9")) { if (alph > 0.5) { Gem = GameObject.FindGameObjectWithTag("Gem9"); gemsys_clone = Instantiate(gemsys, Gem.transform.position, Quaternion.identity); SoundManager.PlaySound("gem"); Object.Destroy(Gem); score = score + 10; scoreBoard.text = "Score: " + score; Destroy(gemsys_clone.gameObject, 2f); } } else if (other.gameObject.CompareTag("Gem11")) { if (alph > 0.5) { Gem = GameObject.FindGameObjectWithTag("Gem11"); gemsys_clone = Instantiate(gemsys, Gem.transform.position, Quaternion.identity); SoundManager.PlaySound("gem"); Object.Destroy(Gem); score = score + 5; scoreBoard.text = "Score: " + score; Destroy(gemsys_clone.gameObject, 2f); } } else if (other.gameObject.CompareTag("Gem12")) { if (alph > 0.5) { Gem = GameObject.FindGameObjectWithTag("Gem12"); gemsys_clone = Instantiate(gemsys, Gem.transform.position, Quaternion.identity); SoundManager.PlaySound("gem"); Object.Destroy(Gem); score = score + 10; scoreBoard.text = "Score: " + score; Destroy(gemsys_clone.gameObject, 2f); } } else if (other.gameObject.CompareTag("Gem13")) { if (alph > 0.5) { Gem = GameObject.FindGameObjectWithTag("Gem13"); gemsys_clone = Instantiate(gemsys, Gem.transform.position, Quaternion.identity); SoundManager.PlaySound("gem"); Object.Destroy(Gem); score = score + 10; scoreBoard.text = "Score: " + score; Destroy(gemsys_clone.gameObject, 2f); } } }
public void Start() { ps = GetComponent <ParticleSystem>(); }
// Use this for initialization void Start() { _particleSystem = GetComponent <ParticleSystem>(); }
// Use this for initialization void Start() { mPS = GetComponent <ParticleSystem>(); mPos = gameObject.transform.position; }
// Use this for initialization void Start() { ps = GetComponent <ParticleSystem>(); ps.Stop(); }
// Use this for initialization void Start() { sp = GetComponent <ParticleSystem> (); Destroy(gameObject, sp.duration); }
// Use this for initialization void Start() { ParticleSystem particleSystem = GetComponent <ParticleSystem>(); Destroy(gameObject, particleSystem.main.duration); // 本だとparticleSystem.durationだが、duplicated }
private void Awake() { ps = GetComponent <ParticleSystem>(); col = GetComponent <Collider>(); }
private void Start() { dirt = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <ParticleSystem>(); isDug = FindObjectOfType <SaveManager>().GetDug(digPlaceName); }
void Start() { projectileHittingPlanet = GetComponent <ParticleSystem> (); }
protected bool Initialize() { // initialize members if (_transform == null) { _transform = transform; } if (pSystem == null) { pSystem = GetComponent <ParticleSystem>(); if (pSystem == null) { return(false); } #if UNITY_5_5_OR_NEWER mainModule = pSystem.main; if (pSystem.main.maxParticles > 14000) { mainModule.maxParticles = 14000; } #else if (pSystem.maxParticles > 14000) { pSystem.maxParticles = 14000; } #endif pRenderer = pSystem.GetComponent <ParticleSystemRenderer>(); if (pRenderer != null) { pRenderer.enabled = false; } if (material == null) { var foundShader = ShaderLibrary.GetShaderInstance("UI Extensions/Particles/Additive"); if (foundShader) { material = new Material(foundShader); } } currentMaterial = material; if (currentMaterial && currentMaterial.HasProperty("_MainTex")) { currentTexture = currentMaterial.mainTexture; if (currentTexture == null) { currentTexture = Texture2D.whiteTexture; } } material = currentMaterial; // automatically set scaling #if UNITY_5_5_OR_NEWER mainModule.scalingMode = ParticleSystemScalingMode.Hierarchy; #else pSystem.scalingMode = ParticleSystemScalingMode.Hierarchy; #endif particles = null; } #if UNITY_5_5_OR_NEWER if (particles == null) { particles = new ParticleSystem.Particle[pSystem.main.maxParticles]; } #else if (particles == null) { particles = new ParticleSystem.Particle[pSystem.maxParticles]; } #endif imageUV = new Vector4(0, 0, 1, 1); // prepare texture sheet animation textureSheetAnimation = pSystem.textureSheetAnimation; textureSheetAnimationFrames = 0; textureSheetAnimationFrameSize = Vector2.zero; if (textureSheetAnimation.enabled) { textureSheetAnimationFrames = textureSheetAnimation.numTilesX * textureSheetAnimation.numTilesY; textureSheetAnimationFrameSize = new Vector2(1f / textureSheetAnimation.numTilesX, 1f / textureSheetAnimation.numTilesY); } return(true); }
private void Start() { currentParticles = GetComponent <ParticleSystem>(); }
void OnCollisionEnter(Collision c) { ContactPoint cp = c.contacts[0]; transform.up = cp.normal; transform.localScale = new Vector3(1.5f, 0.5f, 1); ShakeController shake = Camera.main.gameObject.GetComponent <ShakeController>(); shake.Shake(); if (c.gameObject.tag == "Player") { paddleParticles.Stop(); paddleParticles.transform.position = transform.position; paddleParticles.Play(); sound.clip = paddleSound; sound.Play(); } else if (c.gameObject.tag == "Bricks") { scoreParticles.Stop(); scoreParticles.Play(); ParticleSystem hitParticles = null; for (int i = 0; i < particlePool.Count; i++) { ParticleSystem p = particlePool[i]; if (p.isStopped) { hitParticles = p; Debug.Log("reusing from my pool"); break; } } if (hitParticles == null) { hitParticles = Instantiate(hitParticlesPrefab) as ParticleSystem; particlePool.Add(hitParticles); } hitParticles.transform.up = body.velocity; hitParticles.transform.position = transform.position; hitParticles.Play(); sound.clip = brickSound; sound.Play(); } else if (c.gameObject.tag == "Bricks 2") { scoreParticles.Stop(); scoreParticles.Play(); ParticleSystem hitParticles = null; for (int i = 0; i < particlePool.Count; i++) { ParticleSystem p = particlePool[i]; if (p.isStopped) { hitParticles = p; Debug.Log("reusing from my pool"); break; } } if (hitParticles == null) { hitParticles = Instantiate(hitParticlesPrefab) as ParticleSystem; particlePool.Add(hitParticles); } hitParticles.transform.up = body.velocity; hitParticles.transform.position = transform.position; hitParticles.Play(); sound.clip = brickSound; sound.Play(); } else { sound.clip = wallSound; sound.Play(); } }
void PlayParticles() { ParticleSystem s = Instantiate(particles, TargetPosition.position, transform.rotation) as ParticleSystem; s.Play(); }
static string CheckCulling(ParticleSystem particleSystem) { string text = ""; if (particleSystem.collision.enabled) { text += "\n勾选了 Collision"; } if (particleSystem.emission.enabled) { if (particleSystem.emission.rateOverDistance.curveMultiplier != 0) { text += "\nEmission使用了Current(非线性运算)"; } } if (particleSystem.externalForces.enabled) { text += "\n勾选了 External Forces"; } if (particleSystem.forceOverLifetime.enabled) { if (GetIsRandomized(particleSystem.forceOverLifetime.x) || GetIsRandomized(particleSystem.forceOverLifetime.y) || GetIsRandomized(particleSystem.forceOverLifetime.z) || particleSystem.forceOverLifetime.randomized) { text += "\nForce Over Lifetime使用了Current(非线性运算)"; } } if (particleSystem.inheritVelocity.enabled) { if (GetIsRandomized(particleSystem.inheritVelocity.curve)) { text += "\nInherit Velocity使用了Current(非线性运算)"; } } if (particleSystem.noise.enabled) { text += "\n勾选了 Noise"; } if (particleSystem.rotationBySpeed.enabled) { text += "\n勾选了 Rotation By Speed"; } if (particleSystem.rotationOverLifetime.enabled) { if (GetIsRandomized(particleSystem.rotationOverLifetime.x) || GetIsRandomized(particleSystem.rotationOverLifetime.y) || GetIsRandomized(particleSystem.rotationOverLifetime.z)) { text += "\nRotation Over Lifetime使用了Current(非线性运算)"; } } if (particleSystem.shape.enabled) { ParticleSystemShapeType shapeType = (ParticleSystemShapeType)particleSystem.shape.shapeType; switch (shapeType) { case ParticleSystemShapeType.Cone: case ParticleSystemShapeType.ConeVolume: case ParticleSystemShapeType.Donut: case ParticleSystemShapeType.Circle: if (particleSystem.shape.arcMode != ParticleSystemShapeMultiModeValue.Random) { text += "\nShape的Circle-Arc使用了Random模式"; } break; case ParticleSystemShapeType.SingleSidedEdge: if (particleSystem.shape.radiusMode != ParticleSystemShapeMultiModeValue.Random) { text += "\nShape的Edge-Radius使用了Random模式"; } break; default: break; } } if (particleSystem.subEmitters.enabled) { text += "\n勾选了 SubEmitters"; } if (particleSystem.trails.enabled) { text += "\n勾选了 Trails"; } if (particleSystem.trigger.enabled) { text += "\n勾选了 Trigger"; } if (particleSystem.velocityOverLifetime.enabled) { if (GetIsRandomized(particleSystem.velocityOverLifetime.x) || GetIsRandomized(particleSystem.velocityOverLifetime.y) || GetIsRandomized(particleSystem.velocityOverLifetime.z)) { text += "\nVelocity Over Lifetime使用了Current(非线性运算)"; } } if (particleSystem.limitVelocityOverLifetime.enabled) { text += "\n勾选了 Limit Velocity Over Lifetime"; } if (particleSystem.simulationSpace != 0) { text += "\nSimulationSpace 不等于0"; } if (particleSystem.gravityModifier != 0) { text += "\nGravityModifier 不等于0"; } return(text); }
override public void Update() { ParticleSystemRenderer ren = GetComponentInChildren <ParticleSystemRenderer>(); ren.material.color = ren.trailMaterial.color = gameSettings.GetComponent <GameSettings>().playerColors[playerNumber]; if (GetComponent <PhotonView>().ownerId == PhotonNetwork.player.ID) { //THIS IS THE OWNER //update speeds float tempSpeed = MOVEMENT_SPEED; float tempMax = MAX_SPEED; if (myPowerUp != powerUp.NONE) { timer += Time.deltaTime; } if (timer > 5) { timer = 0; myPowerUp = powerUp.NONE; } if (myPowerUp == powerUp.SPEED) { tempSpeed += 1; tempMax += 1; } //MOVEMENT int verticalMovement = 0; int horizontalMovement = 0; #if UNITY_STANDALONE if (Input.GetKey(thisMovement[MOVE_UP])) { verticalMovement += 1; } if (Input.GetKey(thisMovement[MOVE_DOWN])) { verticalMovement -= 1; } if (Input.GetKey(thisMovement[MOVE_RIGHT])) { horizontalMovement += 1; } if (Input.GetKey(thisMovement[MOVE_LEFT])) { horizontalMovement -= 1; } #endif //Controls for Android devices #if UNITY_ANDROID Touch touch = Input.GetTouch(0); if (!touch.Equals(null)) { horizontalMovement = (int)(touch.deltaPosition.x); verticalMovement = (int)(touch.deltaPosition.y); } #endif xVel += horizontalMovement * tempSpeed * Time.deltaTime; yVel += verticalMovement * tempSpeed * Time.deltaTime; if (horizontalMovement == 0) { xVel -= Time.deltaTime * MOVEMENT_FRICTION * Mathf.Sign(xVel); } if (verticalMovement == 0) { yVel -= Time.deltaTime * MOVEMENT_FRICTION * Mathf.Sign(yVel); } if (Mathf.Abs(xVel) > tempMax) { xVel = tempMax * Mathf.Sign(xVel); } if (Mathf.Abs(xVel) < 0.2f && horizontalMovement == 0) { xVel = 0; } if (Mathf.Abs(yVel) > tempMax) { yVel = tempMax * Mathf.Sign(yVel); } if (Mathf.Abs(yVel) < 0.2f && verticalMovement == 0) { yVel = 0; } Vector3 move = (Vector3.up * yVel) + (Vector3.right * xVel); //move.Normalize(); gameObject.transform.Translate(move); } else { //THIS IS ANOTHER PLAYER } //BOTH if (myPowerUp == powerUp.WIND) { GetComponent <SphereCollider>().radius = PLAYER_WIND_RADIUS; ParticleSystem ps = GetComponentInChildren <ParticleSystem>(); ParticleSystem.ShapeModule shape = ps.shape; shape.radius = PLAYER_PARTICLE_WIND_RADIUS; ParticleSystem.EmissionModule emit = ps.emission; emit.rateOverTime = PLAYER_EMIT_WIND; } else { GetComponent <SphereCollider>().radius = PLAYER_RADIUS; ParticleSystem ps = GetComponentInChildren <ParticleSystem>(); ParticleSystem.ShapeModule shape = ps.shape; shape.radius = PLAYER_PARTICLE_WIND_RADIUS; ParticleSystem.EmissionModule emit = ps.emission; emit.rateOverTime = PLAYER_EMIT; } }
private void ScaleParticleSystem(ParticleSystem particleSystem, float scaleFactor) { SerializedObject particleSystemSerialized; // Record Undo Undo.RecordObject(particleSystem, "Scale Particles"); // Transform if (scalePosition) { particleSystem.transform.localPosition *= scaleFactor; } // Speed #if UNITY_5_3_OR_NEWER ParticleSystem.MinMaxCurve minMaxCurve; ParticleSystem.MainModule main = particleSystem.main; minMaxCurve = main.startSpeed; minMaxCurve.constant *= scaleFactor; minMaxCurve.constantMin *= scaleFactor; minMaxCurve.constantMax *= scaleFactor; ScaleCurve(minMaxCurve.curveMin, scaleFactor); ScaleCurve(minMaxCurve.curveMax, scaleFactor); main.startSpeed = minMaxCurve; minMaxCurve = main.startSize; minMaxCurve.constant *= scaleFactor; minMaxCurve.constantMin *= scaleFactor; minMaxCurve.constantMax *= scaleFactor; ScaleCurve(minMaxCurve.curveMin, scaleFactor); ScaleCurve(minMaxCurve.curveMax, scaleFactor); main.startSize = minMaxCurve; minMaxCurve = main.gravityModifier; minMaxCurve.constant *= scaleFactor; minMaxCurve.constantMin *= scaleFactor; minMaxCurve.constantMax *= scaleFactor; ScaleCurve(minMaxCurve.curveMin, scaleFactor); ScaleCurve(minMaxCurve.curveMax, scaleFactor); main.gravityModifier = minMaxCurve; #else particleSystem.startSpeed *= scaleFactor; particleSystem.startSize *= scaleFactor; particleSystem.gravityModifier *= scaleFactor; #endif // Items needing Serialized particleSystemSerialized = new SerializedObject(particleSystem); particleSystemSerialized.FindProperty("ShapeModule.angle").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("ShapeModule.radius").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("ShapeModule.length").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("ShapeModule.boxX").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("ShapeModule.boxY").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("ShapeModule.boxZ").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("VelocityModule.x.scalar").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("VelocityModule.y.scalar").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("VelocityModule.z.scalar").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("ClampVelocityModule.magnitude.scalar").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("ClampVelocityModule.dampen").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("ClampVelocityModule.x.scalar").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("ClampVelocityModule.y.scalar").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("ClampVelocityModule.z.scalar").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("ForceModule.x.scalar").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("ForceModule.y.scalar").floatValue *= scaleFactor; particleSystemSerialized.FindProperty("ForceModule.z.scalar").floatValue *= scaleFactor; particleSystemSerialized.ApplyModifiedProperties(); }
public void Start() { ps = GetComponent <ParticleSystem>(); psr = GetComponent <ParticleSystemRenderer>(); psr.sortingLayerName = LayerName; }
private void Start() { m_ParticleSystem = GetComponent <ParticleSystem>(); }
void Awake() { ptclSys = GetComponent <ParticleSystem>(); }
private void Awake() { ps = GetComponent <ParticleSystem>(); }
internal static bool IsStopped(ParticleSystem root) { return((!ParticleSystemEditorUtils.playbackIsPlaying && !ParticleSystemEditorUtils.playbackIsPaused) && !ParticleSystemEditorUtils.playbackIsScrubbing); }
// Use this for initialization void Start() { particles = particleObj.GetComponent <ParticleSystem> (); particles.Stop(); }
private void HandleKeyboardShortcuts() { Event evt = Event.current; if (evt.type == EventType.KeyDown) { int changeTime = 0; if (evt.keyCode == ((Event)kPlay).keyCode) { if (EditorApplication.isPlaying) { // If world is playing Pause is not handled, just restart instead Stop(); Play(); } else { // In Edit mode we have full play/pause functionality if (!ParticleSystemEditorUtils.playbackIsPlaying) { Play(); } else { Pause(); } } evt.Use(); } else if (evt.keyCode == ((Event)kStop).keyCode) { Stop(); evt.Use(); } else if (evt.keyCode == ((Event)kReverse).keyCode) { changeTime = -1; } else if (evt.keyCode == ((Event)kForward).keyCode) { changeTime = 1; } if (changeTime != 0) { ParticleSystemEditorUtils.playbackIsScrubbing = true; float previewSpeed = ParticleSystemEditorUtils.simulationSpeed; float timeDiff = (evt.shift ? 3f : 1f) * m_TimeHelper.deltaTime * (changeTime > 0 ? 3f : -3f); ParticleSystemEditorUtils.playbackTime = Mathf.Max(0f, ParticleSystemEditorUtils.playbackTime + timeDiff * (previewSpeed)); foreach (ParticleSystem ps in m_SelectedParticleSystems) { ParticleSystem root = ParticleSystemEditorUtils.GetRoot(ps); if (root.isStopped) { root.Play(); root.Pause(); } } ParticleSystemEditorUtils.PerformCompleteResimulation(); evt.Use(); } } if (evt.type == EventType.KeyUp) { if (evt.keyCode == ((Event)kReverse).keyCode || evt.keyCode == ((Event)kForward).keyCode) { ParticleSystemEditorUtils.playbackIsScrubbing = false; } } }
void OnEnable() { particles = particleObj.GetComponent <ParticleSystem> (); particles.Stop(); menuObj.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); }
internal void PlayBackInfoGUI(bool isPlayMode) { EventType oldEventType = Event.current.type; int oldHotControl = GUIUtility.hotControl; string oldFormat = EditorGUI.kFloatFieldFormatString; EditorGUIUtility.labelWidth = 110.0f; if (!isPlayMode) { EditorGUI.kFloatFieldFormatString = s_Texts.secondsFloatFieldFormatString; if (Time.timeScale == 0.0f) { using (new EditorGUI.DisabledScope(true)) { EditorGUILayout.FloatField(s_Texts.previewSpeedDisabled, 0.0f); } } else { ParticleSystemEditorUtils.simulationSpeed = Mathf.Clamp(EditorGUILayout.FloatField(s_Texts.previewSpeed, ParticleSystemEditorUtils.simulationSpeed), 0f, 10f); } EditorGUI.kFloatFieldFormatString = oldFormat; EditorGUI.BeginChangeCheck(); EditorGUI.kFloatFieldFormatString = s_Texts.secondsFloatFieldFormatString; float playbackTime = EditorGUILayout.FloatField(s_Texts.previewTime, ParticleSystemEditorUtils.playbackTime); EditorGUI.kFloatFieldFormatString = oldFormat; if (EditorGUI.EndChangeCheck()) { if (oldEventType == EventType.MouseDrag) { ParticleSystemEditorUtils.playbackIsScrubbing = true; float previewSpeed = ParticleSystemEditorUtils.simulationSpeed; float oldplaybackTime = ParticleSystemEditorUtils.playbackTime; float timeDiff = playbackTime - oldplaybackTime; playbackTime = oldplaybackTime + timeDiff * (0.05F * previewSpeed); } playbackTime = Mathf.Max(playbackTime, 0.0F); ParticleSystemEditorUtils.playbackTime = playbackTime; foreach (ParticleSystem ps in m_SelectedParticleSystems) { ParticleSystem root = ParticleSystemEditorUtils.GetRoot(ps); if (root.isStopped) { root.Play(); root.Pause(); } } ParticleSystemEditorUtils.PerformCompleteResimulation(); } // Detect start dragging if (oldEventType == EventType.MouseDown && GUIUtility.hotControl != oldHotControl) { m_IsDraggingTimeHotControlID = GUIUtility.hotControl; ParticleSystemEditorUtils.playbackIsScrubbing = true; } // Detect stop dragging if (m_IsDraggingTimeHotControlID != -1 && GUIUtility.hotControl != m_IsDraggingTimeHotControlID) { m_IsDraggingTimeHotControlID = -1; ParticleSystemEditorUtils.playbackIsScrubbing = false; } } int particleCount = 0; float fastestParticle = 0.0f; float slowestParticle = Mathf.Infinity; foreach (ParticleSystem ps in m_SelectedParticleSystems) { ps.CalculateEffectUIData(ref particleCount, ref fastestParticle, ref slowestParticle); } EditorGUILayout.LabelField(s_Texts.particleCount, GUIContent.Temp(particleCount.ToString())); bool hasSubEmitters = false; int subEmitterParticles = 0; foreach (ParticleSystem ps in m_SelectedParticleSystems) { int subEmitterParticlesCurrent = 0; if (ps.CalculateEffectUISubEmitterData(ref subEmitterParticlesCurrent, ref fastestParticle, ref slowestParticle)) { hasSubEmitters = true; subEmitterParticles += subEmitterParticlesCurrent; } } if (hasSubEmitters) { EditorGUILayout.LabelField(s_Texts.subEmitterParticleCount, GUIContent.Temp(subEmitterParticles.ToString())); } if (fastestParticle >= slowestParticle) { EditorGUILayout.LabelField(s_Texts.particleSpeeds, GUIContent.Temp(slowestParticle.ToString(s_Texts.speedFloatFieldFormatString) + " - " + fastestParticle.ToString(s_Texts.speedFloatFieldFormatString))); } else { EditorGUILayout.LabelField(s_Texts.particleSpeeds, GUIContent.Temp("0.0 - 0.0")); } if (!EditorApplication.isPlaying) { EditorGUILayout.LayerMaskField(ParticleSystemEditorUtils.previewLayers, s_Texts.previewLayers, SetPreviewLayersDelegate); ParticleSystemEditorUtils.resimulation = GUILayout.Toggle(ParticleSystemEditorUtils.resimulation, s_Texts.resimulation, EditorStyles.toggle); } ParticleEffectUI.m_ShowBounds = GUILayout.Toggle(ParticleEffectUI.m_ShowBounds, ParticleEffectUI.texts.showBounds, EditorStyles.toggle); EditorGUIUtility.labelWidth = 0.0f; }
void SetParticle() { var obj = Selection.activeGameObject; copyPs = obj.GetComponent <ParticleSystem> (); }