はじめに
Unity 2018.1.0b2 の新機能の「Vector2.Perpendicular」を使用することで
指定された2Dベクトルに対して垂直な2Dベクトルを取得することができます
使用例
using UnityEngine; public class Example : MonoBehaviour { private void Awake() { print( Vector2.Perpendicular( new Vector2( 1, 0 ) ) ); // ( 0, 1 ) print( Vector2.Perpendicular( new Vector2( 0, -1 ) ) ); // ( 1, 0 ) print( Vector2.Perpendicular( new Vector2( -1, 0 ) ) ); // ( 0, -1 ) print( Vector2.Perpendicular( new Vector2( 0, 1 ) ) ); // ( -1, 0 ) } }