mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-24 02:45:39 +03:00
04.07.2022
This commit is contained in:
36
Heli_with_panels/Assets/Scripts/Panel2D/pedals.cs
Normal file
36
Heli_with_panels/Assets/Scripts/Panel2D/pedals.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class pedals : MonoBehaviour
|
||||
{
|
||||
private Vector3 mousePosition;
|
||||
public float moveSpeed = 1.2f;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void OnMouseDrag()
|
||||
{
|
||||
//mousePosition = Camera.main.ScreenToWorldPoint(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<45 && rotation_z>-45)
|
||||
{
|
||||
transform.localRotation = Quaternion.Euler(0f, 0f, rotation_z);
|
||||
|
||||
//int angle_int = Mathf.RoundToInt(rotation_z);
|
||||
|
||||
Debug.Log("угол"+ rotation_z);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user