using UnityEngine;
using System.Collections;

public class GetHit : MonoBehaviour {
	public float fForceHit = 10;
	DetermineWinner determineWinner;

	public AudioSource patito;

	// Use this for initialization
	void Start () {
		determineWinner = GameObject.Find ("DetermineWinner").GetComponent<DetermineWinner>();
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	void OnTriggerEnter (Collider other) 
	{
		if (other.tag == "Car")
		{
			//print ("Hit!");
			patito.Play();
			this.transform.parent.rigidbody.isKinematic=false;
			this.transform.parent.rigidbody.AddExplosionForce(fForceHit,transform.position-Vector3.forward*2-Vector3.up,10);
			this.gameObject.SetActive(false);
			determineWinner.bFox = true;
		}
	}
	public void Jump(float fHorizontalAxis)
	{
		fForceHit = 1450;
		this.transform.parent.rigidbody.isKinematic=false;
		this.transform.parent.rigidbody.AddExplosionForce(fForceHit,transform.position-(transform.right*fHorizontalAxis).normalized-Vector3.up/2,10);
//		this.gameObject.SetActive(false);
	} 
}
