|
|
ÅëÇÕÀº Ŭ·¡½º »ç¿ëÇ϶ó 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; |