using UnityEngine;
using System.Collections;

public class RotateFacingMovement : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	void FixedUpdate () {
		RotateToFacing();
	}

	private void RotateToFacing()
	{
		Vector2 diff = rigidbody2D.velocity;
		float dx = diff.x;
		float dy = diff.y;
		float aimangle = Mathf.RoundToInt(Mathf.Atan2(dx, dy) * -180/Mathf.PI);
		transform.eulerAngles = new Vector3(0,0,aimangle);
	}
}
