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 crusherxman · Mar 08, 2013 at 10:54 PM · particleexplosion

How to create a Particle effect after a time limit

Hello! I'm currently testing a few levels for my project, and I needed to create an explosion after a short time limit. (For exemple: An explosion after 5 seconds)

I have my explosion particle set in place, but I just need a script to activate my explosion after a time limit.

If you guys have any kind of script that works or else a another answer that sounds familliar to this one, please post them below! :D

Thanks!

~LittleL0L

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by $$anonymous$$ · Mar 09, 2013 at 01:13 AM

Try this:

 //js
 
 function Start()
 {
      particleEmitter.enabled = false; // turn the particle system off at startup
      yield WaitForSeconds (5); // wait for 5 seconds
      particleEmitter.enabled = false; // turn the particle system on
 }
Comment
Add comment · Show 4 · 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 crusherxman · Mar 09, 2013 at 01:45 PM 0
Share

I always get this error:

$$anonymous$$issingComponentException: There is no 'ParticleEmitter' attached to the "explosion" game object, but a script is trying to access it.

avatar image $$anonymous$$ · Mar 11, 2013 at 12:43 AM 0
Share

That's because you didn't attach the script to the gameobject that actually has a particle system, or you are using shrukin and not legacy, in witch case it should be

function Start() {

  yield WaitForSeconds (5); // wait for 5 seconds
  ParticleSystem.Play(); // turn the particle system on

}

Sorry the code isn't formatted: I'm doing this on my tablet

avatar image crusherxman · Mar 11, 2013 at 09:27 PM 0
Share

Still dosen't work:

Assets/Timer.js(3,19): BCE0020: An instance of type 'UnityEngine.ParticleSystem' is required to access non static member 'Play'.

avatar image dr-sklz · Jan 06, 2018 at 04:40 AM 0
Share

Hey guys just saw this thread, and although I highly doubt crusherxman is still in any need of help after all these years, someone might else might be having a similar issue. Ben-Jarrell 's code is very useful and is what I used, and if you are using a relatively new version of Unity (Which uses Shuriken) see Ben's comment (2nd above $$anonymous$$e). This will probably give you an error (See the comment just above $$anonymous$$e) if you haven't declared a variable for ParticleSystem. Just add this above his function Start line :

private var ParticleSystem : ParticleSystem;

Works on $$anonymous$$e, and I hope I helped someone :)

avatar image
0

Answer by RyanZimmerman87 · Mar 09, 2013 at 02:32 AM

yield WaitForSeconds(); is probably the superior method for performance.

Another easy way to do it is just create an int variable timer. Set it to 0 on Start. Then do something like this:

 int timer = 0;
 
 Update()
 {
 
 if (timer > your desired number)
 {


 //put your particle effect/explosion stuff here
 timer = 0;
 your condition = false;
 }
 
 }
 
 
 In FixedUpdate()
 {
 
 if (your condition)
 {
 
 ++timer;
 }
 }

Comment
Add comment · Show 3 · 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 $$anonymous$$ · Mar 09, 2013 at 04:14 AM 0
Share

But this will increment timer every physics step if the "your condition" variable is true, witch will base the timer off of the physics fps, not off of the actual time

Edit: in your code that you wrote, you forgot to declare methods with void and "your condition" is not a possible variable name nor was it declared as a boolean

avatar image crusherxman · Mar 09, 2013 at 01:39 PM 0
Share

So you are saying that this script is not vaild?

avatar image $$anonymous$$ · Mar 09, 2013 at 08:01 PM 0
Share

it wont compile, so i guess not

avatar image
0

Answer by SectionScreen · Mar 09, 2013 at 12:53 PM

var lifeTime = 1.0;

function Awake ()

{ Destroy (gameObject, lifeTime);

}

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 crusherxman · Mar 10, 2013 at 10:27 PM 0
Share

Didn't work well... :(

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

13 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

Related Questions

How to instantiate a particle and make it play? 1 Answer

Making detonator explosions follow the gameobject 2 Answers

scripting Impact explosion 1 Answer

Explosive like in COD 4? 1 Answer

Help on a Power-Up Sequence 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