Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ilyamez · Jan 19, 2016 at 02:20 PM · 2d-platformerparticlesystemparticle systembug-perhapsemission

ParticleSystem.emission randomly wont reset

Hi everybody, So, Im trying to gradually turn two particle systems on and off via code In Unity 5.3.1f1. The system are on a toggleable platform (which I've made into a prefab) and there are multiple duplicates of the same platform.

the problem is that, when i activate to turn off and on cycle a few times one or more random platform wont start emitting the particles again.. alt text

If i pause the and check the editor the emission module appears to be toggled off or on as it should, but the particles wont render.

here's the code I'm using:

 using UnityEngine;
 using System.Collections;
 
 public class TimedPlatform : MonoBehaviour {
     BoxCollider2D col;
     float tempTime;
     public Transform rayStart;
     public Transform rayEnd;
     ParticleSystem bricks;
     ParticleSystem laser;
     ParticleSystem[] particles;
     ParticleSystem.EmissionModule em;
     ParticleSystem.EmissionModule emTwo;
     bool disabled = false;
     Color bricksColor;
     // Use this for initialization
     void Start () {
         particles = GetComponentsInChildren<ParticleSystem> ();
         col = GetComponentInChildren<BoxCollider2D> ();
         bricks = particles [0];
         laser = particles [1];
         bricksColor = bricks.startColor;
         em = bricks.emission;
         emTwo = laser.emission;
     }
 
     void DisablePlatform(){
         emTwo.enabled = false;
         em.enabled = false;
         col.enabled = false;
 }
     IEnumerator TimeOut(){
         yield return new WaitForSeconds (3);
         DisablePlatform ();
     }
         
     void FixedUpdate(){
         Vector3 startPoint = new Vector3 (rayStart.position.x, rayStart.position.y, 0);
         Vector3 endPoint = new Vector3 (rayEnd.position.x, rayEnd.position.y, 0);
         RaycastHit2D ray = Physics2D.Linecast(startPoint, endPoint);
         Debug.DrawLine(startPoint, endPoint, Color.red);
 
         if(ray.collider != null){
             if(ray.collider.tag == "Player"){
                 if (!disabled) {
                     tempTime = Time.fixedTime;
                     bricks.startColor = Color.red;
                     disabled = true;
                     StartCoroutine (TimeOut ());
                 }
             }
         }
         if (disabled) {
             if (tempTime + 10f < Time.fixedTime) {
                 emTwo.enabled = true;
                 em.enabled = true;
                 bricks.startColor = bricksColor;
                 col.enabled = true;
                 disabled = false;
             }
         }
     }
 }




I've tried using a few variations of this, like using IEnumirators instead of fixedTime, and while the code seemed to work the end result was the same.

Any Ideas?

report.png (235.6 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Jack_In_The_Sack · Jul 09, 2016 at 08:23 AM

If you haven't figured it out yet, I believe I know what the problem is.

Try turning all of the lines in your script that have startColor into comments. Then, test the game to see if the particles emit as they should. If they do, then startColor was causing the issue.

If the alpha of the color that you are trying to set startColor to is too low, then the particles will not render. You can manually set the alpha of the colors in the script by using color.a. Example: bricksColor.a = 255

Hopefully this helps.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Make Start Color setting in particle system control _EmissionColor 1 Answer

Particle system activate onTriggerEnter2D 2 Answers

Particles don't always play 2 Answers

Line Renderer Emission module error 0 Answers

I want to pause and clear a particle system and be able to start it again, but I am using the Sparkle Rising particle which has no Particle System? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges