Unity 相机朝向与目标之间的夹角

using UnityEngine;

public class MyTest : MonoBehaviour
{
    public Transform cameraTransform;
    public Transform target;

    void Update()
    {
        float angle = Vector3.Angle(cameraTransform.forward, target.position - cameraTransform.position);
        Debug.LogError("夹角:" + angle);
    }
}

你可能感兴趣的:(unity,游戏引擎,游戏)