using UnityEngine;
using System.Collections;
public class ExFollow : MonoBehaviour {
public Transform[] Target = new Transform[2];
Vector3 diff;
int count = 0;
int index = 0;
// Use this for initialization
void Start () {
GetDiff();
}
void GetDiff(){
diff = Target[index].position - transform.position;
}
// Update is called once per frame
void Update () {
if(Input.GetKeyDown(KeyCode.Space) && index < Target.Length){
transform.position += diff * 0.1f;
count++;
if(count > 10){
count = 0;
index++;
GetDiff();
}
}
}
}
'Computer Language > 유니티' 카테고리의 다른 글
z축으로 전진 잔진 (0) | 2014.04.29 |
---|---|
Target.position.x 에 대한 고찰 (0) | 2014.04.29 |
좌표값을 입력해놓고 이리저리 움직여 보자 (0) | 2014.04.29 |
벡터 크기증가와 이동 (0) | 2014.04.29 |
좌우로 움직이는 로봇 (0) | 2014.04.29 |