°ÔÀÓ±â¼úÀÚ·á
¤ýÀÛ¼ºÀÚ ¹èÀçȯ
¤ýÀÛ¼ºÀÏ 2011-09-22 (¸ñ) 11:34
¤ýȨÆäÀÌÁö http://ugame.tu.ac.kr/webboard
¤ýÃßõ: 0  ¤ýÁ¶È¸: 929      
¤ýIP: 210.xxx.56
Unity3D-Overview: Vectors
ÅëÇÕÀº Ŭ·¡½º »ç¿ëÇ϶ó Vector3 ¸ðµÎ 3Â÷¿ø º¤Å͸¦ ³ªÅ¸³»´Â ³»³». 3Â÷¿ø º¤ÅÍÀÇ °¢ ±¸¼º ¿ä¼Ò´Â ±×°ÍÀÇ x,y¿Í zÀÇ ¸â¹ö º¯¼öµéÀ» ÅëÇØ Á¢±ÙÇÒ¼ö ÀÖ´Ù. Note: ÀÌ°ÍÀº ÀÚ¹Ù½ºÅ©¸³Æ®¿Í Boo¿¡¼­ ÀÛ¾÷ÇÑ´Ù. C#¿¡¼­ ´ç½ÅÀº º¤ÅÍÀÇ »õ ÀνºÅϽº¸¦ ¸¸µé°í ±×°ÍÀ» ÇÒ´çÇØ¾ß ÇÒ °ÍÀÌ´Ù. var aPosition : Vector3;
aPosition.x = 1;
aPosition.y = 1;
aPosition.z = 1;


´ç½ÅÀº ¶ÇÇÑ »ç¿ëÇÒ ¼ö ÀÖ´ÙVector3 ¸ðµç ±¸¼º ¿ä¼Ò¸¦ Çѹø¿¡ ÃʱâÈ­ÇÏ´Â »ý¼ºÀÚ ±â´ÉÀ».

1. JavaScript
var aPosition = Vector3(1, 1, 1);

2. C#
using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
public Vector3 aPosition = new Vector3(1, 1, 1);
}

Vector3 also defines some common values as constants.

1. JavaScript
var direction = Vector3.up; // °°Àº Vector3(0, 1, 0);

2. C#
using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
public Vector3 direction = Vector3.up;
}

Operations on single vectors are accessed the following way:

1. JavaScrpit
SomeVector.Normalize();

2. C#
using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void Awake() {
SomeVector.Normalize();
}
}

And operations using multiple vectors are done using Vector3 class functions:

1. JavaScript
var oneVector : Vector3 = Vector3(0,0,0);
var otherVector : Vector3 = Vector3(1,1,1);

var theDistance = Vector3.Distance(oneVector, otherVector);

2. C#
using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
public Vector3 oneVector = new Vector3(0, 0, 0);
public Vector3 otherVector = new Vector3(1, 1, 1);
public float theDistance = Vector3.Distance(oneVector, otherVector);
}

(Note that you have to write Vector3. in front of the function name to tell Javascript where to find the function. This applies to all class functions.)

You can also use the common math operators to manipulate vectors: combined = vector1 + vector2;






  0
2500
    N     ºÐ·ù     Á¦¸ñ    ±Û¾´ÀÌ ÀÛ¼ºÀÏ Á¶È¸
14 ÀÏ¹Ý Unity3D-Overview: The most important classes(3) ¹èÀçȯ 2011-09-22 1166
13 ÀÏ¹Ý Unity3D-Overview: The most important classes(2) ¹èÀçȯ 2011-09-22 1079
12 ÀÏ¹Ý Unity3D-Overview: The most important classes(1) ¹èÀçȯ 2011-09-22 953
11 ÀÏ¹Ý Unity3D-Overview: Writing Scripts in C# ¹èÀçȯ 2011-09-22 1927
10 ÀÏ¹Ý Unity3D-Overview: Coroutines & Yield ¹èÀçȯ 2011-09-22 1047
9 ÀÏ¹Ý UnIty3D-Overview: Instantiate ¹èÀçȯ 2011-09-22 870
8 ÀÏ¹Ý Unity3D-Overview: Member Variables & Global Variables ¹èÀçȯ 2011-09-22 945
7 ÀÏ¹Ý Unity3D-Overview: Vectors ¹èÀçȯ 2011-09-22 929
6 ÀÏ¹Ý Unity3D-Overview: Accessing Other Game Objects ¹èÀçȯ 2011-09-22 988
5 ÀÏ¹Ý Unity3D-Overview: Accessing Other Components ¹èÀçȯ 2011-09-22 897
4 ÀÏ¹Ý Unity3D-Overview: Keeping Track of Time ¹èÀçȯ 2011-09-22 932
3 ÀÏ¹Ý Unity3D-Overview: Common Operations ¹èÀçȯ 2011-09-22 879
2 ÀÏ¹Ý ³Í ÇÒ ¼ö ÀÖ¾î °­»ó¿¡ 2011-03-22 907
1 ÀÏ¹Ý ÀϾ ±è±¤¼® 2011-03-22 873
123