유니티 3D 프로젝트 4 (오브젝트 이동)

박준식·2022년 7월 19일
0

Unity3D

목록 보기
4/7

<게임 오브젝트 이동>
1. transform 변수 : 스크립트와 오브젝트는 1대 1 관계임, 항상 생성되어 있음

  1. transform.Translate(Vector3 translation, Space relativeTo= Space.Self) : vector만큼 이동(순간이동)

  2. transform.position = :
    1) Vector3.MoveTowards(Vector3 current, Vector3 target, float maxDistanceDelta) : 일정한 속도로 이동
    2) Vector3.SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime, float maxSpeed= Mathf.Infinity, float deltaTime= Time.deltaTime
    ) : 가속도를 적용하여 이동, 보통 currentVelocity는 Vector3.zero 사용, smoothTime이 작을 수록 빠름
    3) Vector3.Lerp(Vector3 a, Vector3 b, float t) : 선형보간, t가 작을 수록 느림
    4) Vector3.SLerp(Vector3 a, Vector3 b, float t) : 포물선 이동, t가 작을 수록 느림

  3. Time.deltaTime : 프레임 사이의 시간, 프레임이 적으면 커지고 많으면 작음, 성능에 상관없이 같은 거리를 이동할 수 있음
    1) transform.Translation(translation Time.deltaTime)
    2) Vector3.(a,b,t
    Time.deltaTime)

0개의 댓글