Unity2014. 8. 5. 18:02

레일에서 카메라 이동


using UnityEngine;

using System.Collections;


public class CameraRig : MonoBehaviour {


public Transform camera;

public Transform start;

public Transform dest;

public float duration = 10f;


private float _t;


void Start(){

_t = 0f;

transform.position = start.position;

}

void Update()

{

_t += Time.deltaTime; //경과 시간 구하기.

float p = Mathf.InverseLerp (0f, duration, _t);

transform.position = Vector3.Lerp 

( start.position, dest.position, -(1f -p)*(1f -p) +1f );  // 속도가 느려지는

//transform.position = Vector3.Lerp 

// ( start.position, dest.position, -p*p  +1f);

}

void OnDrawGizmos()

{

Gizmos.color = Color.yellow;

Gizmos.DrawLine (

transform.position, camera.position);

}

}



'Unity' 카테고리의 다른 글

Trail Renderer  (0) 2014.08.06
Build 설정 및 실행  (0) 2014.08.06
오브젝트를 3개 이상 먹으면 Game Over 처리  (0) 2014.08.05
GUI Text 는  (0) 2014.08.05
플레이어에서 충돌 물체 삭제 처리  (0) 2014.08.05
Posted by 코드버무려