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 itsboshytime · Apr 01, 2014 at 08:08 PM · c#particlesparticle systemrestartapplication.loadlevel

Application.LoadLevel and particle system

Hello,

I've ran into a problem with the particle system. I have an object that when it gets destroyed it explodes and i play a particle system. This works on the first load, but when i restart the level the next time it dies the particle ystem does not activate.

This is the restart :

 if (GUI.Button (new Rect (411, 311, 311, 111), "Restart")) 
         {
             Application.LoadLevel("MainGame");



         }

And this is the destroy function

 using UnityEngine;
 using System.Collections;
 
 public class Destroy : MonoBehaviour {
     
     private Timer managerScript;
     public ParticleSystem death;
     
 
     void Start () {
         GameObject gameControllerObject  = GameObject.FindWithTag("GameController");
         managerScript = gameControllerObject.GetComponent <Timer>();
         death.Stop();
     
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 
     
 
     void OnTriggerEnter2D(Collider2D other){
         Debug.Log(other.gameObject.name);
         if (other.gameObject.tag.Equals("Enemy")){
             managerScript.showMenu = true;
             death.transform.position = gameObject.transform.position;
             death.Play();
             Destroy(gameObject);
 
             
         }
         
     }
 
 
 
     
 }




what am i doing wrong?

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 itsboshytime · Apr 02, 2014 at 06:20 AM 0
Share

Nothing? I assume there is a bug with application.load level but i cannot be sure.

1 Reply

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

Answer by FirstLaw · Apr 02, 2014 at 08:23 AM

I think that when you are destroying your gameobject you are also destroying your particle! and so its not available when you load the level again... is your particle system left active in memory? if so , then i suspect your destroy function is removing the particle.

Also when loading the same level try doing it this way

 change   Application.LoadLevel("MainGame"); 
 to       Application.LoadLevel(Application.loadedLevel);

that may help . then try to see if your particle is getting destroyed and never coming back .... you might want to consider something like Object.DontDestroyOnLoad function to help you keep your particle... if that is the case.. or if anything let the particle disapear or move back to where you have it in memory once you have used it and unlink it from your Gameobject. also consider creating the particle each time the object is spawned ... that might help too

cheers i hope this helps

Comment
Add comment · Show 2 · 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 itsboshytime · Apr 02, 2014 at 05:09 PM 0
Share

chaging Application.LoadLevel("$$anonymous$$ainGame"); to Application.LoadLevel(Application.loadedLevel);

seems to have worked. Thanks!

avatar image FirstLaw · Apr 02, 2014 at 05:36 PM 0
Share

no problem just make sure to pick it as the correct answer! glad to have helped

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

21 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

Related Questions

Rain particles are getting affected by the fog 2 Answers

Destroy particles based on bounds not lifetime 0 Answers

Laser beam using particle system Unity2d. 0 Answers

Renderer on object disabled after level reload 1 Answer

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