using UnityEngine;
using System.Collections;

public class pulsevelocity : MonoBehaviour {
	public float thrust; // the pushing force value, just equate it to the value you want
	Vector3 playa;
	Vector3 particlez;
	Vector2 x_y_ratios;
	// Use this for initialization
	void Start () {

	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void OnTriggerEnter(Collider col)
	{
		if (col.gameObject.name.Contains("Meteor") && col.transform.parent == null) 	
		{
			playa = transform.position;
			particlez = col.transform.position;
			x_y_ratios = new Vector2(particlez.x-playa.x,particlez.y-playa.y).normalized;
			col.rigidbody.velocity += new Vector3(thrust*x_y_ratios.x,thrust*x_y_ratios.y,0f) * 10.0f;
		}
		if (col.gameObject.name.Contains("core") && col.transform.parent == null) 	
		{
			playa = transform.position;
			particlez = col.transform.position;
			x_y_ratios = new Vector2(particlez.x-playa.x,particlez.y-playa.y).normalized;
			col.SendMessage("pulsePushed", x_y_ratios);
		}
	}
}
