x


Instantiating Particle System and Editing Base Settings

I've been attempting to Instantiate a particle system using an empty Game Object in front of the player model, however I get errors such as:

"MissingComponentException: There is no 'ParticleEmitter' attached to the "Main Camera" game object, but a script is trying to access it."

As far as I know i'm not accessing anything that should be parented to the main camera, i'm using GameObject.Find() to search for it. I should mention that i've also tried GameObject.FindWithTag() to search for it.

function Air_Push(power : int, duration : float){

if(!power){

    Debug.Log("[Air Push] Power Not Set");

} else if(!duration){

    Debug.Log("[Air Push] Duration Not Set");

} else{

    GameObject.Find("Air Particles").particleEmitter.maxEnergy = duration;
    GameObject.Find("Air Particles").particleEmitter.minEnergy = (particleEmitter.maxEnergy - 0.5);
    GameObject.Find("Air Particles").particleEmitter.localVelocity.z = power;
    GameObject.Find("Air Particles").particleEmitter.emit = true;

    yield WaitForSeconds(duration);

    GameObject.Find("Air Particles").particleEmitter.emit = false;
    Destroy(GameObject.Find("Air Particles"));

}
}

I wish to keep the ParticleSystem as a prefab for future purposes as i'll be giving players only a few of the available weapons/spells, so I won't parent it to the player unless absolutely necessary, I don't want a lone particle system hanging around on a player who hasn't selected to use it from the weapon selection menu.

more ▼

asked Jan 22 '12 at 03:21 AM

luckyluke007 gravatar image

luckyluke007
31 1 1 1

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3443
x176
x116
x108

asked: Jan 22 '12 at 03:21 AM

Seen: 512 times

Last Updated: Jan 22 '12 at 03:21 AM