image1 image2 image3

HELLO I'M VIET|WELCOME TO MY PERSONAL BLOG|I LOVE TO DO CREATIVE THINGS

Unity bài 4: Tọa độ và Vector


Nội dung bài viết
  1. Vector 2 chiều và Pythago
  2. Vector 3 chiều


I. Vector 2 chiều và Pythago

        Vector2 vector = new Vector2(23);


Các vector tĩnh
        Vector2 vector = new Vector2(23);
        Vector2 vectorZero = Vector2.zero;
        Vector2 vectorOne = Vector2.one;
        Vector2 vectorLeft = Vector2.left;
        Vector2 vectorRight = Vector2.right;
        Debug.Log("Vector (2,3): " +vector);
        Debug.Log("Vector Zero " +vectorZero);
        Debug.Log("Vector One: " +vectorOne);
        Debug.Log("Vector Left: " +vectorLeft);
        Debug.Log("Vector Right: " +vectorRight);

  • Để tìm kích thước cạnh huyền trong tam giác vuông ta dùng Vector.magnitute

        Vector2 vector = new Vector2(34);
        Debug.Log("Vector magnitute: " +vector.magnitude);

Kết quả thu được là: 5

II. Vector 3 chiều

  • Vector 3 chiều cũng giống như Vector 2
        Vector3 vector = new Vector3(3412);
        Debug.Log("Vector magnitute: " +vector.magnitude);

Share this:

CONVERSATION

0 nhận xét:

Đăng nhận xét

Thank you!