|
|
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; } } |