using UnityEngine;
using System.Collections;

public class ShadowScript : MonoBehaviour {
	public GameObject ShadowPrefab;
	GameObject g;

	void Start () {
		g = Instantiate (ShadowPrefab,transform.position, new Quaternion ()) as GameObject;
	}

	void Update () {
		Vector3 p = transform.position;
		if (p.y < 0) {
			g.transform.position = new Vector3 (p.x, -100f, p.z);
		} else {
			g.transform.position = new Vector3 (p.x, 0.01f, p.z);
		}

		g.transform.eulerAngles  = new Vector3(90f, 0f, 0f);
	}

	void OnDestroy()
	{
		Destroy (g);
	}

}
