°ÔÀÓ±â¼úÀÚ·á
¤ýÀÛ¼ºÀÚ ¹èÀçȯ
¤ýÀÛ¼ºÀÏ 2011-09-22 (¸ñ) 11:04
¤ýȨÆäÀÌÁö http://ugame.tu.ac.kr/webboard
¤ýÃßõ: 0  ¤ýÁ¶È¸: 932      
¤ýIP: 210.xxx.56
Unity3D-Overview: Keeping Track of Time
Time Ŭ·¡½º´Â ¾ÆÁÖ Áß¿äÇÑ Å¬·¡½º º¯¼ö¶ó ºÒ¸®´Â °ÍÀº Æ÷ÇÔÇÑ´Ù deltaTime. ÀÌ º¯¼ö´Â ¸¶Áö¸· ÅëÈ­ ÀÌÈÄ ½Ã°£ÀÇ ¾çÀ» Æ÷ÇÔÇÑ´Ù Update or FixedUpdate (´ç½ÅÀÌ ³»ºÎ¿¡ ÀÖ´ÂÁöÀÇ ¿©ºÎ¿¡ µû¶ó Update or a FixedUpdate function).

±×·¡¼­ ¾Õ¼± ¿¹Á¦´Â, °³Ã¼°¡ ÀÏÁ¤ÇÑ ¼Óµµ°¡ ¾Æ´Ñ ÇÁ·¹ÀÓ ¼Óµµ¿¡ ÀÇÁ¸ÇÏ¿© ȸÀüÇÒ ¼ö ÀÖµµ·Ï ¼öÁ¤µÇ¾ú´Ù:

1. JavaScript
function Update() {
transform.Rotate(0, 5 * Time.deltaTime, 0);
}

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

public class example : MonoBehaviour {
void Update() {
transform.Rotate(0, 5 * Time.deltaTime, 0);
}
}

Moving the object:

1. JavaScript
function Update() {
transform.Translate(0, 0, 2 * Time.deltaTime);
}

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

public class example : MonoBehaviour {
void Update() {
transform.Translate(0, 0, 2 * Time.deltaTime);
}
}

If you add or subtract to a value every frame chances are you should multiply with Time.deltaTime. When you multiply with Time.deltaTime you essentially express: I want to move this object 10 meters per second instead of 10 meters per frame. This is not only good because your game will run the same independent of the frame rate but also because the units used for the motion are easy to understand. (10 meters per second)

Another example, if you want to increase the range of a light over time. The following expresses, change the radius by 2 units per second.

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void Update() {
light.range += 2.0F * Time.deltaTime;
}
}
  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 1926
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 944
7 ÀÏ¹Ý Unity3D-Overview: Vectors ¹èÀçȯ 2011-09-22 928
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 872
123