help
Root Question Message
// private void Update()
{
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mousePos.z = 0f;
Vector3 aimDirection = (mousePos - transform.position).normalized;
if(changeDirection.x == -1)
{
angle = (Mathf.Atan2(aimDirection.y, aimDirection.x) * Mathf.Rad2Deg - 180f);
angle = Mathf.Clamp(angle, -90f, 90f);
print(angle);
}
else if(changeDirection.x == 1)
{
angle = (Mathf.Atan2(aimDirection.y, aimDirection.x) * Mathf.Rad2Deg);
angle = Mathf.Clamp(angle, -90f, 90f);
//print(Mathf.Rad2Deg);
}
zAngle = new Vector3(0, 0, angle);
transform.eulerAngles = zAngle;
}