mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-23 23:55:38 +03:00
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
public class script_arrow_rotate2 : MonoBehaviour
|
|
{
|
|
private Vector3 mousePosition;
|
|
public float moveSpeed = 1.2f;
|
|
|
|
|
|
|
|
|
|
|
|
void OnMouseDrag()
|
|
{
|
|
//mousePosition = Camera.main.ScreenToViewportPoint(Input.mousePosition);
|
|
mousePosition = Camera.current.ScreenToWorldPoint(Input.mousePosition);
|
|
|
|
// вычисляем разницу между текущим положением и положением мыши
|
|
|
|
Vector3 difference = mousePosition - transform.position;
|
|
difference.Normalize();
|
|
// вычисляемый необходимый угол поворота
|
|
float rotation_z = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
|
|
|
|
// Применяем поворот вокруг оси Z
|
|
//if (rotation_z<180 && rotation_z>0)
|
|
//{
|
|
transform.localRotation = Quaternion.Euler(0f, 0f, (rotation_z-90));
|
|
int angle_int = Mathf.RoundToInt (rotation_z);
|
|
|
|
// Debug.Log("угол"+ (-1*rotation_z+180));
|
|
//}
|
|
}
|
|
}
|