• 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 lampshade · Jun 25, 2010 at 11:27 PM · gameobject

Controlling a GameObject Instantiated ParticleSystem Prefab?

Hi,

When the player instantiates a particlePrefab, particles emit at the players position. What I need to do is for when the player moves, I need the particles to move with the player, in the direction the player is going, and also to gradually destroy several of the particles (not all of them at once).

Essentially, the player runs up to a trigger, player instantiates particles, player moves, particles destroy immediately (not what I want). I need to gradually destroy particles in the direction the player moves in...for now, I am working on gradually destroy particles (fading them out) while holder[4].a is > 0.

//In seperate script file public static ParticleAnimator myEmissions ;

myEmissions = (ParticleAnimator) Instantiate(particlePrefab, transform.position, Quaternion.identity); //End seperate script file

public static ParticleAnimator [] emitters ; //Call our coroutine to gradually destroy particles

public static IEnumerator ResetParticles() {

 resetting = true;
 holder = new Color[5];
 holder[4].a = 1;


 while (holder[4].a > 0) 
 {
     foreach (ParticleAnimator m_emitter in emitters) 
     {
         if (m_emitter) 
         {                   
             holder = m_emitter.colorAnimation;
             holder[4].a -= .005f;
             m_emitter.colorAnimation = holder;
         }
     }
 }
 foreach (ParticleAnimator m_emitter in emitters) 
 {
     if (m_emitter) 
     {
         m_emitter.particleEmitter.emit = false;
         m_emitter.particleEmitter.ClearParticles();
     }
 }
     resetting = false;
     sent = false;

 yield return 0;

}

What the above does, without a PreFab instantiation is destroy's particles gradually. I need to be able to use my instantiated GameObject variable because it has the instantiated particle prefab.

Comment
Add comment · Show 5
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 qJake · Jun 25, 2010 at 11:38 PM 0
Share

Let's not post duplicate questions. - http://answers.unity3d.com/questions/13529/foreach-gameobject-condition-error/13535#13535

avatar image lampshade · Jun 25, 2010 at 11:57 PM 0
Share

I reposted my code

avatar image qJake · Jun 26, 2010 at 12:05 AM 0
Share

Yeah, but you also edited your original question, so reposting almost the exact same one is useless. If you need to make edits, edit your original question, don't start an entirely new, duplicate one.

avatar image lampshade · Jun 26, 2010 at 12:06 AM 0
Share

If I take this post down, can I get my point back?

avatar image Mike 3 · Jun 26, 2010 at 01:35 AM 0
Share

$$anonymous$$eh, I just gave you 10 points in another answer ins$$anonymous$$d for you to delete it ;)

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by fireDude67 · Jul 02, 2010 at 05:16 AM

In ParticleEmitter check One Shot.
Drag particle system onto player GameObject.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers

SetActiveRecursively not activating children 2 Answers

Alternatives to GameObject.Find(); 1 Answer

Why does IsSleeping() keep returning false? (Billiard Logic) 0 Answers

How do I extract all the components of a gameobject and place them in to a new gameobject? 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