Computer Language/유니티
좌우로 움직이는 로봇
알 수 없는 사용자
2014. 4. 29. 09:55
using UnityEngine;
using System.Collections;
public class ExVector : MonoBehaviour {
public int mode = 0;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
//transform.position += Vector3.right * 5 * Time.deltaTime;
//transform.position += Vector3.up * 5 * Time.deltaTime;
print (transform.position);
if(mode == 0){
transform.position += Vector3.right * 5 * Time.deltaTime;
if(transform.position.x > 10){
mode = 1;
}
}
if(mode == 1){
transform.position += Vector3.left * 5 * Time.deltaTime;
if(transform.position.x < -10){
mode = 0;
}
}
}
}