앱 만들기/게임

유니티 Vector 클래스끼리 빼기.

나도 처음이야 2019. 7. 31.

// Start is called before the first frame update
    void Start()
    {
        Vector2 startPos = new Vector2(2.0f, 1.0f);
        Vector2 endPos = new Vector2(8.0f, 5.0f);
        Vector2 dir = endPos - startPos;
        Debug.Log(dir);

        float len = dir.magnitude;
        Debug.Log(len);
    }

 

// 벡터간의 빼기를 할 수 있고, 두 점사이의 거리도 구할 수 있다.

 

반응형

댓글