using UnityEngine;
using System.Collections;

public class Shadow : MonoBehaviour 
{
	public Transform player;
	public Transform LightSource;

	float distX;
	float distY;

	float angle;

	// Update is called once per frame
	void Update () 
	{
		//distanges
		distX = player.position.x - LightSource.position.x;
		distY = player.position.y - LightSource.position.y;

		//calculate angle
		angle = Mathf.Atan2 (distY, distX) * 180 / Mathf.PI;


		transform.rotation = Quaternion.AngleAxis (angle + 90, Vector3.forward);
	}
}