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 Mr_Jester · Apr 08, 2013 at 05:09 AM · arrayparticle systememitter

Going to sleep on this one... Help with an emitter array and loop

Hello everyone, I'm following a book called Unity 3.x Game Development essentials by Will Goldstone and I had a quick question about it. I've been trying for the past 2 hours to figure out why my fire will not emit particles at a certain part in the game (after i collect some matches). Oh yes, my problem is that when I do collect the matches and everything is well, upon colliding with my campfire, my particle system for my campfire will not emit the particles (which is a fire and smoke particle effect). I have them turned off on start (play on awake) but I should have them coded to where they will start as soon as I collect some matches and collide with the campfire. Fortunately, the sound plays and the matchGUI is destroyed, the code near the end of the function, so that's good, but the particles will just not emit. My first assumption is that this book is just too outdated, which it is, but everything seems coded correctly. So I was wondering that maybe it is just outdated, and that it is a possibility that I should be using some other code.

Not sure, but here is the function I'm using to make the array and for loop.

   void LightFire (GameObject campfire)
     {    
     ParticleEmitter [] fireEmitters;

     fireEmitters = campfire.GetComponentsInChildren ();
     foreach (ParticleEmitter emitter in fireEmitters)
     {
         emitter.emit = true;
     }
     
     campfire.audio.Play();
     Destroy (matchGUI);
     haveMatches = false;
 }

So in other words, I'm using an array to carry out the same set of commands on multiple objects. This function needs to light the campfire by enabling the emit property of both of my particle systems that are childs of my "campfire" gameobject. Which is the reason I use the GetComponentsInChildren command. I begin my establishing a local array inside my custom function called LightFire. I populated the array with both of the particle emitter components. Then I used a for loop to repeat through this array and perform a command on the emitters in the array. I established a variable called emitter which is passed each entry in the fireEmitters array each time the loop runs. This is then used to address the emit parameter of the Particle Emitter component, setting it to true. Then I have it playing an audioclip, and also destroying a gui and setting my haveMatches boolean to false. Those latter three all work, but the worthless particles will not emit, lol yeeeesh.

Okay guys, sorry if this was very long, but I'm very tired now and I was just really hoping to be as thorough as I possibly could so that everything is clear cut. ANY help would be super awesome, and I know you guys are! :D Good luck, and thank you for dealing with my noviceness! :)

Edit: Eh, I'm trying to format the code to put it into divided columuns but it's just not having it today :/ lol

Re-Edit: HA I GOT IT!

Comment
Add comment · Show 1
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 Fattie · Apr 08, 2013 at 05:10 AM 0
Share

Please EDIT and dramatically shorten your question.

Cut to the absolute core issues. I genuinely want to help but nobody has time to read that much. (Well done on the formatting)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by AlucardJay · Apr 08, 2013 at 06:59 AM

Check the video that updates this part : http://www.youtube.com/watch?v=xnK5g2z9ESQ

Comment
Add comment · Show 1 · 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 Mr_Jester · Apr 09, 2013 at 01:55 AM 0
Share

Awesome! I didnt think to search for this on Youtube lol, thank you so much man!

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

12 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

Related Questions

Multiple Cars not working 1 Answer

Array weapons Wheel scroll switch 1 Answer

Move one of the objects selected from array ? 1 Answer

Error when trying to set variable with array 1 Answer

Help with Array script 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