Im wanting to turn an invisable cylender colder I have place off and on. and I also need to toggle my particle emiter off and on for fire I have never called the off and on swich befor so I was hoping some one could provide me some help.
1 Answer
1Unity makes it really easy to turn a component on and off. Most components have a property enabled that turns them active/inactive.
//Example:
function Start () {
InvokeRepeating("FlipCollider" , 3 , 3);
//Call every 3 seconds.
}
function FlipColider () {
collider.enabled = !collider.enabled;
//flips the current value. Makes it the opposite of what it currently is.
//Most components either have an enabled or active(obsolete) property.
particleSystem.enableEmmission = !particleSystem.enableEmmission;
//The new Shuriken system has a slightly different name for enabled though.
}
I cant get it to make the flame ver die for the 3 seconds i have found another code that works but i cant manage to get it to work as a loop. // Emit particles for 3 seconds particleEmitter.emit = true;yield WaitForSeconds(3); // Then stop particleEmitter.emit = false;
– anon70884200Oh your using the legacy particle emitter. Just replace the your line for the last line of instructions in mine.
– Peter_GI have place it just like this on the innerCore and outterCore of my fire particle effect and it never makes it change. function Start () { InvokeRepeating("FlipCollider" , 10 , 10); //Call every 3 seconds. } function FlipColider () { collider.disable = !collider.disable; //flips the current value. Makes it the opposite of what it currently is. //Most components either have an enabled or active(obsolete) property. particleEmitter.emit = false;yield WaitForSeconds(10); }
– anon708842001. your not flipping anything. Flipping is setting it to equal the opposite of itself. You're just setting emit to false. You need to do: particleEmitter.emit = !particleEmitter.emit;
– Peter_G