turning a particle emiter on/off from script

I’ve created a ball and a firepit.
the firepit has a particle effect that is always on and a collider that is used to trigger a particle effect that is attatched to the ball if the ball falls into the pit.

Right so i have the script attatched to each instance of the pit but this seems un economical in the sense that i have to have the script placed all over the level and also raises the issue of calling another object (ball particle emiter) from the firepit script

heres an example of what i have attatched to the firepit

function OnTriggerEnter(other : Collider)
{

	var contact : String = other.transform.name;
	
	if (contact == "Player")
	{
		Debug.Log ("I'm on FIRE");
	}

}

is there any way i can get the same functionality with a script that i can attatch to the player

Could you perhaps attach an ss?

I’m not sure how this may help but here
http://s922.photobucket.com/albums/ad62/thathomelessguy/?action=view&current=fire.jpg

Okay, so what’s happening is that your player is on fire without even touching the fire?

if so, try using a collider:

Collider [] FireCollider = Physics.OverlapSphere(transform.position, FireEffectsRadius);		

		foreach (Collider col in FireCollider)
		{
			if (col is MeshCollider)
			{
				if (col.collider.gameObject.tag == "Player")
				{
					Debug.Log("Catch Player on Fire..");
				}
			}
		}

I am sorry I do not know the syntax for js : check
documentation.

And also, make sure you have tag’s set up for your player and also your fire emission (however you are emitting your fire particles) game object.

Find the Layers button->Edit Layers and start adding tags appropriately…Let me know what happens :x

no the screenshot just has the fire emiter for the player on to show its position i want to attatch a script to the player to detect weather the player has entered a trigger area that has the name “Fire” if you look closely at the ss you will see the green bounding box of the trigger colliders named “Fire” i’m sorry for the poor comunication.

the particle emitter for the player is a child of the player thus the emiter follows the player so i also need help with toggling the emiter on and off.

If you don’t mind tagging ALL the firepits as “Firepit”, you may want to attach the following code to the player. In this way everytime the character hits any firepit it triggers the effect.

function OnControllerColliderHit(hit : ControllerColliderHit) 
{   
   if (hit.gameObject.tag == "Firepit") 
   { 
      Debug.Log ("I'm on FIRE"); 
   } 

}

Regarding emitter on/off, you may want to use:

var flames : GameObject = GameObject.Find("Fire");
var flameEmitter : ParticleEmitter = flames.GetComponent(ParticleEmitter);
	flameEmitter.emit = true; // or false

this would work if the colider wasn’t a trigger but it needs to be when the player enters a trigger area. i gave it a try and it works fine when i uncheck the is trigger on the collider.
thank you though.
i’ll try the emitter now though thanks

It may also be worth noting that my original script which i attatched to each firepit works perfectly i would just rather attatch a single script to the player so that i can consolidate the functionality in one place rather than having to go around adding it to every instance of firepit trigger

ok so i tried the emiter code with a box collider and it works but is buggy in that it removes the component rather if i declare a false on flameEmitter.emit
here is what i did

var flames : GameObject = GameObject.Find("Fireball"); 
function OnControllerColliderHit(hit : ControllerColliderHit) 
{    
	var flameEmitter : ParticleEmitter = flames.GetComponent(ParticleEmitter);
   if (hit.gameObject.tag == "Firepit") 
   { 		
		
		flameEmitter.emit = true;
		yield WaitForSeconds (2);
		flameEmitter.emit = false;
		Debug.Log ("I'm on FIRE"); 
   } 
}

and it throws up this error

any ideas?

so how do i aply this to a script that requires OnControllerColliderHit or OnTriggerEnter

coroutine is this bit i assume

var flameEmitter : ParticleEmitter = flames.GetComponent

and how do i stop it from removing the particle emiter when i try and set the particle emit to false?

I really hate to do this but i’m stumped so here goes

BUMP