UnityはlookAtなしでオブジェクトの向きをどのように変更し、一定期間向きを回転させることができますか
四元数によるオイラー角へ
関数 Quaternion.LookRotation を使用します。
1. 現在位置とターゲット位置の方向を取得します
Vector3 dir = (new Vector3(desPos.position.x, 0, desPos.position.z) - new Vector3(transform.position.x, 0, transform. position.z)).normalized;
2. LookRotation 関数を使用して方向のクォータニオンを取得します
Quaternion rot = Quaternion.LookRotation(dir);
3. プラグイン DOTween で DORotate の回転を使用して、 angle
transform.DORotate(new Vector3(rot.eulerAngles.x, rot.eulerAngles.y, rot.eulerAngles.z), 1.0f, RotateMode.Fast);
回転方向を秒単位で指定できます。