Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Merrick · May 29, 2014 at 02:18 AM · c#particlesystem

How do I start particle emission in c#?

Hi, I'm following a begginer's tutorial (since I have just started with programming). The Idea is that when the player aproach a collider, the particle emission should start. This is the code:

 void LightFire (GameObject campfire)
     {
         ParticleEmitter[] fireEmitters;
         fireEmitters = campfire.GetComponentsInChildren<ParticleEmitter>();
         foreach(ParticleEmitter emitter in fireEmitters)
         {
             emitter.emit = true;
         }
         campfire.audio.Play();
         Destroy(matchGUI);
 
     }


Everything else in the code is run smoothly, the audio starts and the GUITexture is destroyed, but the emitters won't start. Can Someone tell me why?

TY

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
Best Answer

Answer by supernat · May 29, 2014 at 04:02 AM

It's one of the following most likely:

1) fireEmitters is coming back null. Which means the children in your campfire game object do not contain any ParticleEmitters.

2) The emitters are there, but they are not active (as in enabled, not as in emitting).

3) The emitters are there and emitting but not where you think they are in the scene (maybe they somehow got moved to another part of the world)

4) The emitters are emitting particles in a render layer that is not being rendered by the current camera (it's cull mask rejects them).

5) Lighting is wrong in the actual game but works fine in the Scene editor (so you see it in the scene and not in the game). For this one, you should be able to select the emitters on the campfire gameobject in the scene editor while the game is running and see quads rising up as particles

6) The particles are so small you can't see them in-game.

Comment
Add comment · Show 6 · 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
avatar image Merrick · May 29, 2014 at 05:21 PM 0
Share

It's none of the above. I have two particle Systems attached to the campfire (one is fire, the other is Smoke). For what I understand, there is two checks that needs to be checked for the Emitter to emit particles. One is the Emission, and the other is the Play on awake. I tried to leave one checked and the other not and in the other system I tried to do it otherwise, and none work.

If I check both the works fin, but they start emitting at the start of the scene which is not the idea, the player must start the Fire by colliding with it.

Any other idea?

avatar image supernat · May 29, 2014 at 06:18 PM 0
Share

Open the scene editor while the particles should be active, click on the fire and/or smoke emitter, and is the emit flag set in the Inspector? I didn't think particle emitters had a Play on Awake. Particle Systems do.

Are you absolutely sure you are using Particle Emitter and not Particle System, so you're running an older version of Unity I take it? If it is getting into line 7 above (which is the item #1 in my answer), then I have no further idea.

avatar image Merrick · May 29, 2014 at 11:11 PM 0
Share

I'm using a Particle System. I'm confused, is there a particle Emitter other than the one that comes with the Particle System? What code should I use?

I did what you sugested with the Inspector set on both Particle System and nothing happens...

Any other sugestion?

I'm using Unity 4.3.4

avatar image rutter · May 29, 2014 at 11:20 PM 0
Share

In version 3.5, Unity introduced a new particle engine.

ParticleEmitter is the old system (also called "Legacy").

ParticleSystem is the new system (also called "Shuriken").

They leave both classes exposed so that old games don't break. The vast majority of new development is done with ParticleSystem.

avatar image Merrick · May 30, 2014 at 04:44 AM 0
Share

I'm using Particle System, but still can't manage to make it work. This is the code as I undestood it for the link you provided.

     void LightFire (GameObject campfire)
     {
         ParticleSystem[] fireEmitters;
         fireEmitters = campfire.GetComponentsInChildren<ParticleSystem>();
         foreach(ParticleSystem system in fireEmitters)
         {
             system.Play;
         }
         campfire.audio.Play();
         Destroy(matchGUI);
 
     }

But now the console gives me this error

Assets/Scripts/Inventory.cs(70,44): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Could you help me a little bit more...

DUH!! I forgot the () after Play... IT WOR$$anonymous$$S!!! Thanks for the help!!

Show more comments

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

24 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

hi i have a problem with sync my particle system with mirror to the other players(only host gets the system wotking) 0 Answers

Unity's Particle System seems to be absolutely broken when it comes to Emit() 0 Answers

Assign random start lifetime for particle system from script 2 Answers


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