public Camera cam;
public GameObject firePoint;
private Vector3 mousePos;
private float mouseAngle;
private Vector3 firePointLookDir;
void update(){
mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
mousePos.z = 0f;
firePointLookDir = (mousePos - firePoint.transform.position).normalized;
if (playerMovement.facingRight)
{
mouseAngle = Mathf.Clamp(Mathf.Atan2(firePointLookDir.y, firePointLookDir.x) * Mathf.Rad2Deg, -90, 90);
}
else if (playerMovement.facingRight == false)
{
mouseAngle = Mathf.Clamp(Mathf.Atan2(firePointLookDir.y, firePointLookDir.x) * Mathf.Rad2Deg, 90, 270); // I tryied differents angles combinaisons here, the 90/270 combinaison is the one doing half the job
}
firePoint.transform.eulerAngles = new Vector3(0, 0, mouseAngle);
}
public Camera cam;
public GameObject firePoint;
private Vector3 mousePos;
private float mouseAngle;
private Vector3 firePointLookDir;
void update(){
mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
mousePos.z = 0f;
firePointLookDir = (mousePos - firePoint.transform.position).normalized;
if (playerMovement.facingRight)
{
mouseAngle = Mathf.Clamp(Mathf.Atan2(firePointLookDir.y, firePointLookDir.x) * Mathf.Rad2Deg, -90, 90);
}
else if (playerMovement.facingRight == false)
{
mouseAngle = Mathf.Clamp(Mathf.Atan2(firePointLookDir.y, firePointLookDir.x) * Mathf.Rad2Deg, 90, 270); // I tryied differents angles combinaisons here, the 90/270 combinaison is the one doing half the job
}
firePoint.transform.eulerAngles = new Vector3(0, 0, mouseAngle);
}