Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
1
Question by deciduous · Dec 20, 2018 at 08:58 PM · particle systemparticle emitter

Particle system playing but not emitting any particles.

So I have a very strange issue. In my game I have players with particle systems that emit as they move and use the ribbon function in order to simulate a trail (using this method over trail renderer so I can tap into particle collision events). There is also screen wrap in the game for the player characters, and in order to get this work without drawing a ribbon between opposite ends of the screen on a player's wrap I unparent the current particle system on the initial side of the screen, set it to destroy when it's finished, and instantiate a new one parented to the player on the other side of the screen. The strange bit is that, under certain conditions, the newly instantiated system will not emit any particles. Here is a list of features of this issue that confound me:


-If I pause the game and restart it, or if I highlight anything in the hierarchy, the particle system begins emitting like normal until I wrap again. Sometimes the particle system just works too. It's not always broken.


-This only occurs when I wrap from the bottom of the screen, and if I instead jump to the top and wrap it will instantiate a system that works fine.


-The newly instantiate particle system is playing and is in the correct position, but when the game is paused and it's highlighted it shows that 0 particles are being emitted even though the emission module's rate over distance is set to 10. If I log the particle systems states it says it's playing and emitting even when no particles are being emitted.


I've tried several hacky solution attempts including setting the particle system prefab inactive and setting it active in code, setting the system to NOT play on awake then telling it to play once instantiated, etc, but none of them works whatsoever.


Here is the code for the particle instantiation:

 //this function checks to see if the player should wrap and calls the wrap funtion
 private void CheckForWrap()
     {
         if(transform.position.x < leftConstraint)
         {
             TriggerWrap();
             transform.position = new Vector3(rightConstraint, transform.position.y, 0f);
         }
         else if (transform.position.x > rightConstraint)
         {
             TriggerWrap();
             transform.position = new Vector3(leftConstraint, transform.position.y, 0f);
         }
         else if (transform.position.y > topConstraint)
         {
             TriggerWrap();
             transform.position = new Vector3(transform.position.x, bottomConstraint, 0f);
         }
         else if(transform.position.y < bottomConstraint)
         {
             TriggerWrap();
             transform.position = new Vector3(transform.position.x, topConstraint, 0f);
         }
     }

 //this function runs in the character controller when a screen wrap is detected
 public override void TriggerWrap()
     {
         currentTrail.transform.parent = null;
         var main = currentTrail.GetComponent<ParticleSystem>().main;
         main.loop = false;
         main.stopAction = ParticleSystemStopAction.Destroy;
 
         currentTrail = Instantiate(trailPrefab, trailSlot.transform.position, Quaternion.identity, trailSlot.transform);
         currentTrail.GetComponent<PlayerTrail>().AttachToPlayer(this);
     }


Here is the code that is attached to the particle system and run when a new prefab is instantiated from the character controller:

     //this is the function that is called when a new particle system is instantiated
     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;
             }
         }


Here is a screenshot of the particle system prefab that is used:

alt text


Any help would be appreciated!

playertrail.png (36.3 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 ElanaHonor · Nov 20, 2019 at 10:43 AM

try to change the child (the particle) position from 0,0,0 to small amount like 0.1,0.1,0.1 hope that will save your problem as it solved mine

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

103 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

world space simulation isn't affecting particle rotation 0 Answers

PARTICLE SYSTEM NEITHER EMITTING NOR PLAYING (BY SCRIPT) 3 Answers

How to layer particle systems going through other particle systems 2 Answers

I want Particle System don't quit any situation. 1 Answer

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