|
Hi, 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?
(comments are locked)
|
|
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 Would I start by making a new script like, ParticleEmitter and addthat script to the player game object?
May 28 '10 at 10:19 PM
lampshade
No, you can't make a script called "ParticleEmitter". That's a reserved word. I'm talking about adding the Emitter component to your current game object, using the Components menu at the top of Unity.
May 28 '10 at 10:42 PM
qJake
Alright, I added the component (I guess I was just being stubborn, thinking I was right) and I am not getting the error, which is great. But I am still left with needing to change the particle color from white to red.
May 28 '10 at 11:06 PM
lampshade
Would I need to add the Particle Animator component instead? I am not getting any color functionality with just the Ellipsoid Particle Emitter.
May 28 '10 at 11:16 PM
lampshade
That does not work b/c the code is wanting the Ellipsoid Particle Emitter, like I have.
May 28 '10 at 11:17 PM
lampshade
(comments are locked)
|
