Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by PilgrimFlowers · Feb 16, 2020 at 01:20 PM · particlesystemeffectspickups

How to destroy a looping particle effect that is part of an object?,How to destroy a particle effect attached to an object?

I have done a lot of looking up on this, but nothing seems to really fit what I'm trying to do (everyone is talking about a temporary effect like an explosion, or something that will last a duration, then end). My game is a 2D rogue-like, and I have pickups. I have created a little 8-bit "glow" particle effect and attached it to one of the pickup objects which is set to destroy on collision. The pickup itself works absolutely perfectly, no flaws at all. I have set both the pickup object and the particle effect to be a prefab and attached the effect to the pickup object as a child. So for obvious reasons, the particle effect needs to be set to "Loop" because I need it to continuously play until the object is picked up. In theory, when the object gets destroyed, the effect should as well since it's a child? Well, that's not happening...And I have even called to destroy the effect before the object and still nothing. The particle effect will continue on forever even after the gameobject is destroyed and I'm at a loss here. Find below my code for the pickup. Everything that is commented out are things that I have already tried before but did not work (just left them in there so you could see what I've tried).

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class HealthContainer : MonoBehaviour { //public ParticleSystem glowPartEffect; public GameObject glowEffect;

 // Start is called before the first frame update
 void Start()
 {
     //Instantiate(glowEffect, transform.position, transform.rotation);
 }

 // Update is called once per frame
 void Update()
 {
     
 }

 //public void OnBecameVisible()
 //{
     //Instantiate(glowEffect, transform.position, transform.rotation);
 //}

 //when the player collides with the pickup
 public void OnTriggerEnter2D(Collider2D other)
 {
     if(other.tag == "Player")
     {
         PlayerHealthController.instance.AddHeartContainer();
         Destroy(glowEffect);
         //Destroy(this.gameObject.GetComponent<ParticleSystem>());
         //DestroyImmediate(glowEffect);
         //ParticleSystem.Destroy(glowPartEffect);
         Destroy(gameObject);
         AudioManager.instance.PlaySFX(25);
         AudioManager.instance.PlaySFX(26);
     }
 }

 //public void OnBecameInvisible()
 //{
     //Destroy(glowEffect);
 //}

}

Comment
Add comment · Show 2
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 PilgrimFlowers · Feb 15, 2020 at 10:50 PM 0
Share

For the record, I have no problem instantiating the effect which happens when the pickup is dropped, and it instantiates properly and everything. Just can't seem to get rid of it once it's there. Haha.

avatar image PilgrimFlowers · Feb 15, 2020 at 11:14 PM 0
Share

Sooo... Shortly after posting this, I realized my mistake and finally got it to behave properly... I forgot to add the particle effect to the object before making it a prefab... So the effect was still a separate object and not following the script...

0 Replies

· Add your reply
  • Sort: 

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

198 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 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

Particle system how to emit continuous fog? 0 Answers

Sub emitter particle effect only plays once. 2 Answers

How can i fix/properly use this code ? 0 Answers

Grayscale Effect only on one object (two cameras) 1 Answer

Visual Effects Graph effect disables if i slowly look away 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