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

public class PlayerWeaponMovement : MonoBehaviour {

    public static PlayerWeaponMovement instance;   
    private float speed = 10f;

  //  public PlayerCrosshair crossHair;
   // private Vector3 crossHairPosition;
   
    void Start() {
      //  crossHair = FindObjectOfType<PlayerCrosshair>();
        //crossHairPosition = crossHair.transform.position;
    }

    void FixedUpdate() {
        Vector2 direction = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
        float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
        Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward);
        transform.rotation = Quaternion.Slerp(transform.rotation, rotation, speed * Time.deltaTime);               
    }
}
