Unity Development 3.x Will Goldstone Particle Chapter

Hey,

So the particle system has changed a bit since this book was written and I’ve gotten far in the chapter but I have no idea why I can’t get one part of my script to work. Everything works perfectly, but I can’t seem to get the fire to light when my character collides with it.

void OnControllerColliderHit(ControllerColliderHit col)
	{
		// if our character collider hits with an object called campfire.
		if(col.gameObject.name == "campfire")
		{
			if(haveMatches)
			{
				//we will run LightFire function with those arguments.
				LightFire(collider.gameObject);
			}
			else
			{
				textHints.SendMessage("ShowHint", "I could use this campfire to signal for help... if only I could light it..");
			}
		}
	}
	
	//passing in the collider of the campfire, we will refer to it as campfire.
	void LightFire(GameObject campfire)
	{
		ParticleEmitter[] fireEmitters;
		
		//assigning campfire array to have the partical emitter components in the campfires' childs.
		fireEmitters = campfire.GetComponentsInChildren<ParticleEmitter>();
		//variable named emitter which passes thru all of the particle emitters in the campfires childs
		foreach(ParticleEmitter emitter in fireEmitters)
		{
			emitter.emit = true;
		}
		campfire.audio.Play();
		Destroy(matchGUI);
		haveMatches = false;
	}

The lightfire script runs, and the matchGUI is destroyed, the audio plays and the haveMatch value gets set to false. The problem is the emit values don’t seem to get checked.

Any ideas?

Nevermind, I figured it out!

Instead of: LightFire(collider.gameObject);

I should have had: LightFire(col.gameObject);