using UnityEngine;
using System.Collections;

public class CharacterEmitter : MonoBehaviour
{

		public GameObject target;
		public GameObject effect;
		float rate = 0.4f;
		float actTime = 1f;
		bool emitting = false;
		bool emitted = false;

		public void StartEmitting ()
		{
				emitting = true;
		}
		public void stopEmitting ()
		{
				emitting = false;
		}
		void Emit ()
		{
				GameObject go = (GameObject)GameObject.Instantiate (effect, this.transform.position, this.transform.rotation);
				MoveTo mov = go.GetComponent<MoveTo> ();
				mov.target = target;

		}
		// Update is called once per frame
		void Update ()
		{
				if (actTime <= 0 && emitting) {
						Emit ();
						actTime = rate;
				}
				actTime -= Time.deltaTime;

		}
}
