- Home /
unable to disable game object after user input
i have a game object with attached particles.here i want to off the particles(game object) at the start time(in start()function)and if i press a button i want to enable or activate the particle effect which is attached to game object.i.e.,tanker back blast should happen only when missile is triggered.the way i used public gameobject tankerbackblast; start() { //tankerbackblast.particleEmitter.emit = false; tankerbackblast.renderer.enable = false; } update() { if(input.getkeydown(keycode.f)) { //tankerbackblast.particleEmitter.emit = true; tankerbackblast.renderer.enable = true; } i used both ways by accessing emitter and game object renderer in update function. i have unchecked the one shot option of the game object(tankerbackblast)in inspector. thanks in advance.
Answer by dukearena · Nov 20, 2012 at 08:44 AM
Maybe you lost AutoDestruct checkbox in ParticleAnimator... It destroy the object when no particles are active..
Otherwise, for cannonshot I use another method, I think is more simple:
// An empty gameobject child of cannon.
public Transform cannonBulletStart;
// The particles - Set OneShot and AutoDestruct = True
public GameObject shotParticles;
void Update(){
if(Input.KeyCodeDown(KeyCode.f)){
Instanciate(shotParticles, cannonBulletStart.position, cannonBulletStart.rotation);
}
}
(Sorry for errors, I've wrote this code at the moment)
Your answer
Follow this Question
Related Questions
Particle collision problem 0 Answers
How to keep particles moving past an obstacle after they have collided with it? 3 Answers
How to move an entire particle generated Starfield? 2 Answers
How to Instantiate gameObject where a particle dies 2 Answers
Particle billboard is visible if camera is to close. 0 Answers