static public Quaternion GetDirXY(Vector3 start, Vector3 end) { float angle = Vec3Mathf.GetAngle1(start, end); float angleX = GetAngleXY(start, end); float angleZ = 0.0f; if (angle > 90.0f && angle < 270.0f) { angle = -(180.0f - angle); angleZ = 180.0f; } //Debug.Log(angle + " | " + angleX); return(Quaternion.Euler(angleX, -angle, angleZ)); }
// Update is called once per frame void Update() { if (fow.isDanger && target3d != null) { image.enabled = true; } else { image.enabled = false; } if (target3d != null) { float targetAngle = Vec3Mathf.GetAngle1(player.position, target3d.position) + Camera.main.transform.rotation.eulerAngles.y; transform.localPosition = Vec3Mathf.GetCirclePointXZ(canvasCenter.localPosition, targetAngle, rad); float selfAngle = Vec3Mathf.GetAngleCanvas(transform.localPosition, canvasCenter.localPosition); transform.localRotation = Quaternion.Euler(0.0f, 0.0f, selfAngle); } //Debug.DrawLine(canvasCenter.position, new Vector3(canvasCenter.position.x, canvasCenter.position.y + 540.0f, canvasCenter.position.z)); //Debug.DrawLine(canvasCenter.position, transform.position); }
static public Quaternion GetDir(Vector3 start, Vector3 end) { float angle = Vec3Mathf.GetAngle1(start, end); return(Quaternion.Euler(0, -angle, 0));; // Крутим }