- Home /
Changing the radius of Unity 5.3 Particle Systems
I have been hyped about the 5.3 release after hearing that 2D colliders would now be supported by Particle Systems, and that the Buoyancy Effector is now a reality. However, with the improvements to the particle system in effect, I am left with some difficult problems. Back in 5.2, I could change the width and size of a particle system by changing the scale of the game object that holds it. But now, I cannot change the x scale because it now scales the entire particle effect, meaning that the particles are now strangely elongated. I assumed that when the particle system changes went live, the particle system functions that were initially impossible to change via script would become changeable. However, while most of the other functions are changeable, the SHAPE of the particle system is get only, and I cannot change individual components of the shape by constructing a new ParticleSystems.Shape (just an example, different in reality) and setting it to the particle system shape. Does anyone have an idea for a workaround, or am I missing something?
Any help would be greatly appreciated.
Answer by mbenn250 · Dec 12, 2015 at 06:52 PM
Turns out that the problem has to be solved by using the following code (thanks to the forums for this answer).ParticleSystem.ShapeModule shapeModule = GetComponent <ParticleSystem> ().shape;
You can then change the shapeModule's size, which in turn changes the particle effect's size. Not sure why Unity has you do this, but it works.
something wrong here, still can't acess to shape for changing particle system shape radiusParticleSystem.Shape$$anonymous$$odule shape$$anonymous$$odule = GetComponent ().shape;
Easiest solution is to make spaces between < and word to write it. Like .
Answer by Bocharick · Feb 10, 2016 at 06:41 PM
I found solution of changing shape through script.
NOT working:
public ParticleSystem psystem;
void Start(){
psystem.shape.box = new Vector3(2,2,2); // error, couldn't compile
//psystem.shape.box.Set(2,2,2); // has no error, and compile, but has no results
}
Working:
public ParticleSystem psystem;
void Start(){
var x = psystem.shape;
x.box = new Vector3(2,2,2); // solve my problem
//x.box.Set(2,2,2); - still has no error, but still has no results
// if you want change shape cone radius - x.radius = 34345;
}
Hope it will helpfull. I broke my brain till found this solution.
Same here, took me like 1 hour but here is the same chunk of code(just that is for radius):
private ParticleSystem PS2;
var rad2 = PS2.shape;
rad2.enabled = true;
rad2.radius *= whatever_amount_you_want_to_multiply_the_radius_by;
Answer by richardkettlewell · Jan 02, 2016 at 08:41 PM
Also, you can retain the pre 5.3 scaling behaviour by setting the scaling mode in the initial module to Shape only.
Answer by Mikozouzou · Jan 20, 2017 at 04:01 PM
I didn't really find a way to apply the precedent answers to my project, so here is another one that could also help. It works on Unity 5.5.
public ParticleSystem explosionFX;
public float explosionRadius = 1f;
void Explode()
{
ParticleSystem.ShapeModule shapeModule = explosionFX.shape;
shapeModule.radius = explosionRadius;
explosionFX.Play();
}
Answer by Geek314159 · Dec 12, 2015 at 06:47 PM
You could try checking "emission" and changing it from there.
Your answer
![](https://koobas.hobune.stream/wayback/20220612052009im_/https://answers.unity.com/themes/thub/images/avi.jpg)