📜  2d 看统一 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:14.579000             🧑  作者: Mango

代码示例2
//Look at 2D job using the unity jobs system
struct LookAtJob : IJobParallelForTransform
{
    public NativeArray targetPositions;
    public void Execute(int index, TransformAccess transform)
    {
        Vector2 dir = targetPositions[index] - (Vector2)transform.position;
        float angle = math.degrees(math.atan2(dir.y, dir.x));
        transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
    }
}