|
Hi, my problem is simple (please be patient, my knowledge of Unity isn't too extensive). I have a turret gameObject which has 2 pieces, the head and base. The turret has to aim automatically at "zombies" that walk through a trigger that has been attached to the parent object. There are two scripts attached to the head: AimTurret and TurretParticleController. AimTurret: var aiming = false; function Aim(newTarget : Transform) { } function Return(original : Transform) { } function isAiming() { } TurretParticleController: { var aimControl : AimTurret = GetComponent(AimTurret); } The aiming is working fine, and isAiming is also perfect. However when I run this, I get the following error: MissingReferenceException: The object of type 'ParticleEmitter' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. I don't know what I am supposed to do to fix it, and my particle emitter isn't switching on and off like I want it to when the "Zombie" is inside the collider. Thanks in advance for your help
(comments are locked)
|
|
Ensure that Autodestruct is not enabled in the Particle Animator, which will destroy the entire GameObject when all particles have died out, shortly after turning off emissions. http://unity3d.com/support/documentation/Components/class-ParticleAnimator.html Thank you very much! Didn`t let me to give you thumbs up, don`t know why :/
Nov 18 '12 at 04:45 PM
apomarinov
(comments are locked)
|
|
You probably have One Shot enabled on the particle emitter. If you have, it'll fire all particles at once, instead in a constant stream, and then destroy itself. Either turn this of, or keep creating a new one for every 'shot'.
(comments are locked)
|

Do you still get the error if you comment out the line "p.emit = false;" ? Because else this could be the same as lights, when you disable a light you cannot access it anymore. Maybe if you disable particle emission from a particle emitter, it cannot be accessed again.
Im only guessing, thats why this is not in the answer section.
I have exactly the same problem. If I try to set the emit property to false, the emitter seems to disappear (after the last particle has died out, I believe). How are you supposed to be able to turn particle emitters on and off if this destroys the object? The enabled property works, however that just turns the GameObject on and off and leaves the particles suspended in mid-air, which looks silly. I hope there is a solution to this or it can be fixed.