2019年03月22日
【Unity】キャラ正面とターゲットの2点間の角度を三次元ベクトル(Vector3)を使って求める
ベクトルの2点間の角度の求め方をメモ φ(. .)メモメモ
transform.TransformDirection(Vector3.forward);
target.transform.position - transform.position;
Vector3.Angle(手順1のやつ, 手順2のやつ);
こう。
参考サイト:
Vector3.Angleで向いている方向からの角度を得る
htmlまだ直ってないんだけど...。
大丈夫なんだろうか
スポンサードリンク




手順1 : オブジェクトのforwardをワールドスペースで出す
transform.TransformDirection(Vector3.forward);
手順2 : ターゲットへのベクトルを出す
target.transform.position - transform.position;
手順3 : 角度にする
Vector3.Angle(手順1のやつ, 手順2のやつ);
まとめると
こう。
参考サイト:
Vector3.Angleで向いている方向からの角度を得る
余談
htmlまだ直ってないんだけど...。
大丈夫なんだろうか
スポンサードリンク


【このカテゴリーの最新記事】
-
no image
-
no image
-
no image
この記事へのトラックバックURL
https://fanblogs.jp/tb/8659901
※ブログオーナーが承認したトラックバックのみ表示されます。
この記事へのトラックバック
※ ブログに表示されるのは、主の承認が必要なので時間がかかります!
コメントに気づかない場合もありますので、返信が遅れる場合も...