반응형
- 코드 작성
using UnityEngine;
public class AngleCalculator : MonoBehaviour
{
public Transform pointA;
public Transform pointB;
void Start()
{
Vector2 direction = pointB.position - pointA.position;
float angle = Vector2.Angle(Vector2.right, direction);
Debug.Log("Angle between the two points: " + angle);
}
}
- 다른 예시
using UnityEngine;
public class AngleCalculator : MonoBehaviour
{
public Transform pointA;
public Transform pointB;
void Start()
{
Vector3 direction = pointB.position - pointA.position;
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
Debug.Log("Angle between the two points: " + angle);
}
}
반응형