Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 Digital-Phantom · Feb 20, 2015 at 01:56 PM · particlesystemsetactivechild objectenabledgetcomponentinchildren

How to enable/Disable/enable the Particle System Component of a child object on the same object/Parent? (Solved)

I can officially say there 'is' such a thing as information overload, geez I must have read about 40 topics/answers now and I'm still no clearer to solving my issue.

I have a particle System attached to a child object of my player (hierarchy wise that's Player/MainCamera/BoostEffectObject/ParticleSystem

My script is on the player object (parent of the child object)

I think (please correct me if wrong) that I need this to initialise-

 void Awake()
     {
         boostSparkle = GetComponentInChildren<ParticleSystem>();
     }
 

and then I have this in my OnTriggerEnter function -

 boostSparkle.SetActive(true);
 

But I'm getting this error -

"Assets/Scripts/SpeedBoostActivate.cs(32,38): error CS1061: Type UnityEngine.Component' does not contain a definition for SetActive' and no extension method SetActive' of type UnityEngine.Component' could be found (are you missing a using directive or an assembly reference?)"

I've tried different variations and variations using enabled but everything seem to give a compiler error.

Suggestions please guys

???

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

2 Replies

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

Answer by siaran · Feb 20, 2015 at 02:43 PM

You have a reference to the particlesystem, not the gameobject, and particlesystem has no SetActive method. Instead, use bootSparkle.gameObject.SetActive(true) to activate the gameObject. Alternatively, you could just have the gameObject active, disable the emission, and in your code call bootSparkle.enableEmission = true.

Comment
Add comment · Show 17 · 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 siaran · Feb 20, 2015 at 03:15 PM 1
Share

Is the gameObject that contains your particleSystem active? What I meant by disabling the particle system's emission is, go to your particleSystem, then uncheck the 'emission' checkbox.

avatar image siaran · Feb 20, 2015 at 03:52 PM 1
Share

Ah, I see. I'd assumed you just had a looping particlesystem and that the time didn't really matter (that's how I use them the most).

What I think you want to do is set your particlesystem so that -play on awake is disabled -emission is enabled -disable looping -call particleSystem.Play() when it should start playing ins$$anonymous$$d of setting enableEmission to true. (and maybe also .Stop() when it should stop. I dunno, I never use those functions.)

avatar image siaran · Feb 20, 2015 at 03:54 PM 1
Share

I forgot returns don't work, reformatted how I said you should set up your system:

  • play on awake is disabled

    • emission is enabled

    • disable looping

    call particleSystem.Play() when it should start playing ins$$anonymous$$d of setting enableEmission to true

avatar image siaran · Feb 21, 2015 at 01:08 PM 1
Share

...okay, I'm out of ideas on how to get the particlesystem to reset, so how about this: ins$$anonymous$$d of trying to reset your attached particlesystem, put your particlesystem on a prefab, then instantiate that prefab on the trigger (and just have it pla y on awake and have it destroy itself once the particlesystem is done playing). edit:

Something like

 public GameObject boostSparkles;
 
 
 void OnTriggerEnter(Collider collider){
  GameObject go = (GameObject) Instantiate(boostSparkles,  transform.position, transform.rotation);
  //set sparkle effects parent to this transform
  go.parent = transform;
  //Destroy after 5 seconds
  Destroy(go, 5.0f);
 
 
 }


avatar image siaran · Feb 21, 2015 at 01:58 PM 1
Share

ah, it should be go.transform.parent ins$$anonymous$$d of go.parent

Show more comments
avatar image
1

Answer by Shaq · May 29, 2017 at 06:29 AM

I had the same issue, so created empty game Object and placed particles in there

Then just the enabled/disabled the game Object

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

22 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

Related Questions

Set Objects Child to Active/Inactive(Solved) 5 Answers

sync renderer.enabled or SetActive() over network? 0 Answers

works with gameObject but not with Image SetActive vs Enabled 1 Answer

How do I access childs with name and getComponent them ? 4 Answers

Code to turn off ParticleSystem doesn't turn it off in-game, but instead turns it off on the prefab permanently? 0 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