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
2
Question by LatticeworkKnobkerry · Feb 01, 2015 at 06:22 PM · c#animationparticlesshuriken

Is there a way to get a particle system to play WITHOUT calling .Play() from script?

I have some particle systems parented to a rigged character, with several animations on the character. At certain points during the animation, I want to play one of the particle systems, then have it stop, and play again later in the animation.

The situation is - I cannot animate ParticleSystem.enableEmission on that object (for an unrelated reason), so I have made a script that accepts a public ParticleSystem, and when the GameObject holding the script is enabled, it calls ParticleSystem.Play(). Like so:

 using UnityEngine;
 using System.Collections;
 
 public class ParticleAniCtrl : MonoBehaviour {
     public ParticleSystem particle;
     
     void OnEnable() {
         if(particle) {
             if (!particle.isPlaying) {
                 particle.Play();
             }
         }
     }
     
     void OnDisable() {
         if(particle) {
             if (particle.isPlaying) {
                 particle.Stop();
             }
         }
     }
 }
 

(Play on awake is unchecked on the systems I'm using.)

This actually works fine. But this project is going to be sent off to another studio and I am concerned that they are going to ask me to do these animations without adding any new script that isn't in their system already.

I thought of leaving PlayOnAwake checked in the particle system, and simply animating whether the particle system is enabled. The problem is, this doesn't always work if it's not the first playthough for the system - because it doesn't necessarily go back to the beginning when it's disabled and reenabled.

Actually just having .Play() get triggered has exactly the desired effect, I just want to do this without having to use a new script. Is there a way to trigger the particle system to play from the animation timeline?

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 meat5000 ♦ · Feb 01, 2015 at 06:50 PM 0
Share

To fire a dormant system there probably is no way to do it without a script.

Its a basic setup. I wouldn't worry about it.

avatar image Inok · Feb 01, 2015 at 09:22 PM 1
Share

You can trigger the particle system to play from the animation timeline using "animation event" if you need start event with specified keyframe of animation, or you can use "State Behaviour" script. But both methods need to use some script.

4 Replies

· Add your reply
  • Sort: 
avatar image
8

Answer by taxvi · Jan 20, 2018 at 12:19 PM

I've added particle system to a child gameObject, marked PlayOnAwake to true and in the animator I'm toggling gameObject.IsActive on and off.

Not a universal solution but works for me

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
avatar image
1

Answer by Mashimaro7 · Aug 12, 2020 at 08:55 AM

A late response, but for anyone who views this in the future, the way I did it was simply set the emission rate to 0, and it's kind of an annoying script, but this is how I enable it, if (raining) StartRain(); else StopRain();

  public void StartRain()
     {
         ParticleSystem.EmissionModule rn = particles[0].emission;
         rn.rateOverTime = rainRate;
     }
 
     public void StopRain()
     {
         ParticleSystem.EmissionModule rn = particles[0].emission;
         rn.rateOverTime = 0;
     }

I have an array of particle systems, and the "rainRate" is a serialized float that I set in the inspector.

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
avatar image
-1

Answer by SnStarr · Feb 01, 2015 at 09:06 PM

I think an alternative way would be, but I may be wrong.

 ParticleSystem.enable(true);
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 taxvi · Jan 20, 2018 at 12:17 PM 0
Share

I've converted your comment to an answer. One correction though: ParticleSystem does not have a property enable (or at least not a public one) but your on the right track

avatar image
0

Answer by Dannabe1 · Jul 13, 2021 at 03:04 PM

Add event on a keyframe in Animation and call your method to Play a ParticleSystem.

It's true that you have to write a method that calls method ParticleSystem.Play() in a Script but, you decide in the Animation when it will be executed.

Obviously, set ParticleSystem PlayOnAwake = false and Loop = false.

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

(Shuriken) Accessing Particle[] Array Created in Inspector? 3 Answers

Need help with attacking animation!! 1 Answer

Timing particles for animation: Where to begin? 0 Answers

Distribute terrain in zones 3 Answers

The further the distance, the longer particle lifetime. How? 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