📜  指向鼠标 2D Unity - C# 代码示例

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

代码示例1
Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
        difference.Normalize();
        float rotation_z = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
        transform.rotation = Quaternion.Euler(0f, 0f, rotation_z + offset);