Unity
유니티 deltaTime
hsooooo
2021. 8. 8. 14:34
Time.deltaTime이란?
이전 프레임의 완료까지 걸린 시간
deltaTime : 값은 프레임이 적으면 크고, 프레임이 많으면 작음
Time.deltaTime 사용하는 방법
Translate : 벡터에 곱하기 - transform.Translate(Vec * Time.deltaTime);
Vector 함수 : 시간 매개변수에 곱하기 - Vector3.Lerp(Vec1, Vec2, T * Time.deltaTime);
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Move : MonoBehaviour
{
Vector3 target = new Vector3(8, 1.5f, 0);
void Update()
{
Vector3 vec = new Vector3(
Input.GetAxisRaw("Horizontal") * Time.deltaTime,
Input.GetAxisRaw("Vertical") * Time.deltaTime,
transform.Translate(vec)
);
}
}