타겟방향을 따라 회전 하기

using UnityEngine;
using System.Collections;

public class test_rotation : MonoBehaviour {
 
    public Transform target;
    Vector3 lookDir;
 
    void Start () {
 
 }
 
 void Update () {
        
        // 방향은 노멀라이즈 사용
        lookDir = (target.position - transform.position).normalized;
 
        Quaternion from = transform.rotation;
        Quaternion to = Quaternion.LookRotation(lookDir);

        transform.rotation = Quaternion.Lerp(from, to, Time.fixedDeltaTime);
 }
}

댓글

이 블로그의 인기 게시물

날짜 시간 시간차 시간 계산 하기

코루틴에서 CallBack 함수 적용하기

C++ 언어 퍼센트 구하는 방법 / 기본 언어 퍼센트 구하는 방법