using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GunMovement : MonoBehaviour {

    public static Vector3 mousePosition;
    Vector3 gunPosition;
    public static float angle;
    

	// Use this for initialization
	void Start () {
        
    }
	
	// Update is called once per frame
	void Update () {
        mousePosition = Input.mousePosition;
        mousePosition.z = 0f;
        gunPosition = Camera.main.WorldToScreenPoint(transform.position);

        var direction = (mousePosition - gunPosition).normalized;
        transform.up = direction;

        /*
        mousePosition.x = mousePosition.x - gunPosition.x;
        mousePosition.y = mousePosition.y - gunPosition.y;
        angle = Mathf.Atan2(mousePosition.y, mousePosition.x) * Mathf.Rad2Deg;
        transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
        */
    }
}
