I was hoping to be able to turn on/off a particle emitter via the Emit property. In the GUI it looked to be a boolean so figured I could access it that way in code. After looking at the documentation this seems to not be the case or am I missing something? If this doesn’t work is there a way someone could suggest?
My code looks like this:
if (! part.Emit){
part.particleEmitter.Emit = true;
}
The error I am getting is:
Expression cannot be assigned to.
Thanks for the help!
Regards,
– Clint
You want particleEmitter.emit (lower case)
It looks like there is a bug in the Unity documentation for emit
http://unity3d.com/Documentation/ScriptReference/ParticleEmitter.emit.html
It directs you to the function Emit instead, maybe because the web server doesn’t care about case, or something.
Is that all of your script? If it is, you need to put a var at top named “part” and do that drag-and-drop maneuver we discussed in the other thread. Then if you refer to this var as ParticleEmitter, then you can just do part.emit instead of part.particleEmitter.emit. It’s less typing, cleaner, and a teeny tiny bit faster.
-Jon
Cool thanks for the info. Below is the entire script. Look okay?
var showerEmitter : GameObject;
function OnMouseDown(){
if (! showerEmitter.particleEmitter.emit){
showerEmitter.particleEmitter.emit = true;
}
}
function OnMouseUp(){
if (showerEmitter.particleEmitter.emit){
showerEmitter.particleEmitter.emit = false;
}
}
Regards,
– Clint
BTW, should I write a bug about the documentation?
Thansk for all the help!
– Clint
Not necessary i did that myself after reading your post.