mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-24 01:15:41 +03:00
04.07.2022
This commit is contained in:
37
Heli_with_panels/Assets/script_arrow_rotate2.cs
Normal file
37
Heli_with_panels/Assets/script_arrow_rotate2.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
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));
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user