- Home /
Using a Burst in a script
I'm trying to use the burst from a particle system. If someone can help me access the burst on the particle system through a script and run it, that would be very helpful. I'm just trying to simply make it so when I press play, the effect will go off. I know you can do this on particle system itself, but I want to do it by accessing it in a script. I've been using https://docs.unity3d.com/ScriptReference/ParticleSystem.Burst.html as a reference. Sorry if this is a weird question, but I'm pretty new to Unity and I'm still just getting the hang of it.
Answer by Positive7 · Feb 20, 2018 at 04:20 AM
It is under emmision
GetComponent<ParticleSystem>()
.emission.SetBursts(new[]
{
new ParticleSystem.Burst(1f, 10), //float_time, short_count
});
But I guess you just want to use ParticleSystem.Emit
I think this is the correct answer.
@BankShotZombies , if this solves your problem, please reply in a comment. Additionally, you can check this article to see how to access the moduels of a ParticleSystem.
Thank you very much for your help. Would you $$anonymous$$d translating that code into Javascript/Unityscript? That would be much appreciated. Thanks again.
I've rarely used js but I guess it would be something like this :
#pragma strict
function Start()
{
GetComponent.<ParticleSystem>().emission.SetBursts([new ParticleSystem.Burst(1.0f, 10)]);
}
You might also neeed to enable the emmision :
GetComponent.<ParticleSystem>().emission.enabled = true;
Answer by muhammadtahiriqbal · Feb 20, 2018 at 04:48 AM
public ParticleSystem.Burst(float _time, short _count); or public ParticleSystem.Burst particle;
Construct a new Burst with a time and count. https://docs.unity3d.com/ScriptReference/ParticleSystem.Burst-ctor.html
Answer by Lizardsking · Oct 06, 2020 at 10:13 AM
I think you just need to call ps.Play(); It will burst particles every time you call it.
Your answer
Follow this Question
Related Questions
Is their any way to save a particle system when it's not instantiated yet? 2 Answers
Clickable object not properly working 1 Answer
Playmaker: How to use and get variables from other visual scripting or C#? 1 Answer
The spaceship acceleration script is good ? And how to use it with engine ? 0 Answers