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
0
Question by alpayoguz97 · Feb 21, 2021 at 08:10 PM · particlesysteminstantiate prefab

Particle System is not Playing

I made a simple spaceship that has a particlesystem. When I press "space" button, spaceship should fly and particle system should instantiate and play. But it's not playing. It seems in hierarchy as clone but not playing.

As you see, particle effect is instantiating but not playing. It should play bottom of spaceship

Those are codes :

 void FlyShip()
     {
 
 
         if (Input.GetKey(KeyCode.Space))
         {
 
             rb.AddForce(Vector3.up * jumpForce);
 
 
             if (!takeoffSound.isPlaying)
             {
 
                 // _rocketJetParticle is gameobject. 
                 _rocketJetParticle = Instantiate(rocketJetParticle, new Vector3(transform.position.x, transform.position.y - 4, transform.position.z), transform.rotation);
                 takeoffSound.Play();
 
             }
 
         }
 
         else 
         {
             //Destroy(_rocketJetParticle);
             takeoffSound.Stop();
             
         }
 
 
     }

resim-2021-02-21-230553.png (301.4 kB)
Comment
Add comment · Show 3
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 Llama_w_2Ls · Feb 21, 2021 at 08:18 PM 0
Share

In the particle system settings, is it set to Play On Awake?

avatar image alpayoguz97 Llama_w_2Ls · Feb 21, 2021 at 08:40 PM 0
Share

No, its not

avatar image alpayoguz97 alpayoguz97 · Feb 21, 2021 at 08:52 PM 0
Share

Any thoughts ? @Llama_w_2Ls

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Megaboy238 · Feb 21, 2021 at 09:53 PM

Your not really doing it the best way and my way is not the best either but easier.

  1. Create Particle System

  2. Make sure to uncheck 'Play On Awake'

  3. Add Particle system to rocket as child

  4. Position Particle system on the rocket at the boosters

  5. Add [SerializeField] private ParticleSystem _rocketJetParticle; to variable list.

  6. Change void FlyShip() as per below.

  7. Add Particle systems to script in inspector.

FlyShip() { if (Input.GetKey(KeyCode.Space)) { rb.AddForce(Vector3.up * jumpForce);

             if (!takeoffSound.isPlaying)
             {
                 // Start Particle System. 
                 _rocketJetParticle.Play();
                 takeoffSound.Play();
 
             }
         }
         else
         {
             _rocketJetParticle.Stop();
             takeoffSound.Stop();
         }
     }



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 alpayoguz97 · Feb 22, 2021 at 06:41 AM 0
Share

Actually, ı did what you said before. But I think for more optimization, instantiating and destroying is better than that.

avatar image
1

Answer by rh_galaxy · Feb 21, 2021 at 10:03 PM

You shouldn't Instantiate (and destroy) the particle system all the time, just let it exist all the time as a child object and do play and stop.

I don't know when you run FlyShip(), but if it's in update this will result in creating a new particle system every frame, which is not what you want.

 public ParticleSystem oThruster; //set in inspector by dragging the particle system to the variable
 ParticleSystem.EmissionModule oThrusterEmission;
 oThrusterEmission = oThruster.emission;
 //then set on
 oThrusterEmission.enabled = true;
 //or off
 oThrusterEmission.enabled = false;

alt text


particles.jpg (190.7 kB)
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 alpayoguz97 · Feb 22, 2021 at 06:43 AM 0
Share

Hi, actually I did what you said before. But I think for more optimization, instantiating and destroying is better than that. What do you think ?

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

115 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

Related Questions

Is it better to use ParticleSystems on one GameObject OR instantiate ParticleSystems? 1 Answer

How to instantiate particle effect after destroying it 2 Answers

Best way to spread particle system? 1 Answer

Destroy child with Particlesystem will cause error 1 Answer

Changing ParticleSystem attributes at runtime 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