- Home /
Script access to "Ellipsoid" property on Emitter
Quick question: I want to animate the "Ellipsoid" property of an Ellipsoid Particle Animator (the property that sets the size of the invisible "ellipse" where the particles will spawn inside, randomly), but it doesn't seem to be in the "ParticleEmitter" class. Is this a property that's scriptable?
Edit: I've tried using a cylindrical mesh, but the Mesh Emitter just takes a mesh, and it can't be scaled using code at runtime. Anyone else have any ideas of how I could make my emitter emit range "grow" over time? I can't use Force because it messes with some of my other properties and makes the effect of the emitter look weird.
Agreed, It should be accessible via script. I have a dust trail effect which I wanted to reuse for different shaped boulders and just adjust the radius of the particle emitter's ellipsoid but now it seems i will need to create a dust trail prefab for every size boulder and this rules out changing sizes of boulders by code because then the effects wouldn't work.
Hey there, I agree. I found this page while searching for unity change particle emitter ellipse , what a bummer! Now I have to start again, do some tests with mesh emitter and think about a scalable mesh that adds verts depending on size .... bummer =[
Thanks. First time I commented in this webpage so I'm new to the process.
No worries, most new users don't know about the comment system and that little button !
I have been playing around with this tonight, and have made a basic solution to create a mesh for a mesh emitter that is currently just a line, you give it a length and the space between each vert along that line, then the mesh emitter does its thing on each vert. It is basic but works. The next task, and much bigger, will be to create a sphere mesh to emit from, and then expose variables for the number of verts, and sphere XYZ dimensions hopefully replicating the effects of the ellipse settings in the ellipsoid emitter. Anyway, here's the code for the line emitter :
#pragma strict
import System.Collections.Generic;
public var setLength : float = 5.0;
public var spacing : float = 0.25;
public var emitPerUnit : float = 10.0;
private var theEmitter : ParticleEmitter;
private var mesh : $$anonymous$$esh;
private var vertsList : List.< Vector3 > = new List.< Vector3 >();
function Start()
{
theEmitter = GetComponent( ParticleEmitter );
Start$$anonymous$$esh();
//
SetVerts( setLength );
Build$$anonymous$$esh();
SetEmitter();
}
function Update() {
if ( Input.Get$$anonymous$$ouseButtonDown(0) ) {
SetVerts( setLength );
Build$$anonymous$$esh();
SetEmitter();
}
}
function SetEmitter() {
theEmitter.maxEmission = theEmitter.$$anonymous$$Emission = parseInt( setLength * emitPerUnit );
}
function SetVerts( theLength : float )
{
vertsList.Clear();
var count : int = parseInt( theLength / spacing );
for ( var i:int = 0; i < count; i ++ ) {
vertsList.Add( Vector3( 0.0, 0.0, (i * spacing) ) );
}
}
function Start$$anonymous$$esh() {
if ( !mesh ) {
mesh = new $$anonymous$$esh();
GetComponent($$anonymous$$eshFilter).mesh = mesh;
mesh.name = "Particle$$anonymous$$esh";
}
}
function Build$$anonymous$$esh() {
mesh.Clear();
mesh.vertices = vertsList.ToArray();
var tris : int[] = new int[ vertsList.Count * 3 ];
for ( var v:int = 0; v < vertsList.Count; v ++ ) {
tris[v] = $$anonymous$$athf.FloorToInt( v / 3.0 );
}
mesh.triangles = tris;
}
Answer by dhendrix · Apr 01, 2010 at 07:56 PM
Since you can't access the ellipse, you should be able to just use a mesh particle emitter, then scale the mesh. Not quite the same thing, but a compromise that might work.
Oh, and then I could just turn the renderer off on the mesh to make it invisible, yeah... that might work. Thank you for the idea!
Unfortunately, this didn't work. You can't scale the mesh within the code, either. Anyone else have any ideas?
You can scale the mesh with code; change transform.localScale.
Scaling the mesh won't work, but moving the vertices themselves might.
Answer by Tasarran · Jan 10, 2012 at 05:27 AM
It may not be scriptable, but it is exposed in the Animator.
Just assign a new Animation to the emitter, and you have access to everything.
I know this works, because I was just animating the Ellipsoid on my project today.
Just trying this out now with the shape parameters of a Shuriken particle system. I can use an animation to animate the "Shape $$anonymous$$odule.box X/Y/Z" properties. This works in preview mode when I run the animation in the Editor. But: (1) the entire particle system scales, including previously emitted particles, and (2) when I press play I get three particles emitted and the whole thing dries up.
Answer by Eric5h5 · Apr 01, 2010 at 12:27 AM
No, it's not scriptable.
... That's it? Just "no"?
I need to animate this property somehow, do you have any suggestions as to how I could do that?
Really no, it is really not scriptable. ;) I'm not sure what else I can say...not everything is exposed to scripting. You can go here and vote for it: http://feedback.unity3d.com/forums/15792-unity/suggestions/163600-scripting-expose-more-classes-properties-to-scrip?ref=title
What an oversight! I don't understand why any variable I can see in the Editor wouldn't be scriptable! At the very least there should be a catch-all function like Component.setVariable(string, object)
Your answer
![](https://koobas.hobune.stream/wayback/20220612140916im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
how to turn a particle emitter on & off with a rigidbody trigger? 2 Answers
How do I use emissionRate in scripting? 1 Answer
Timetrail script creating 2 trails and not destroying the second 0 Answers
ARK of the COVENANT | How do I trigger Particles to come out once the top has been removed? 0 Answers