What I am trying to do is change the color of my particles which is a prefab attached to my game object. Everytime I press the 'h' key on the keyboard the particle system instantiates. I am trying to change the colors of each particle from white to red by iterating through the array.
I've tried to do this with the following code within an OnTriggerStay function:
Getting the error:
MissingComponentException: There is no 'ParticleEmitter' attached to the "Player" game object, but a script is trying to access it. You probably need to add a ParticleEmitter to the game object "Player". Or your script needs to check if the component is attached before using it.
I know for a fact that the particle emitter is attached to the gameobject, player. Why would the particle emission happen upon pressing 'h' if it wasnt?
When you instantiate something, you create a new game object. You cannot instantiate a component and place it on the current game object.
You need to either insert your particle emitter onto your game object in the editor, and then turn it on and off as needed at runtime, or create the particle emitter entirely with code (using
answered May 28 '10 at 10:00 PM