using UnityEngine;
using System.Collections;
public class Move3 : MonoBehaviour {
public float moveSpeed = 5f;
public float turnSpeed = 180f;
CharacterController _cc;
// Use this for initialization
void Start () {
_cc = GetComponent<CharacterController> (); //CharacterController 값을 받아와라.
}
// Update is called once per frame
void Update () {
float h = Input.GetAxis ("Horizontal");
float v = Input.GetAxis ("Vertical");
//_cc.Move (new Vector3 (0f, 0f, v) * moveSpeed * Time.deltaTime);
_cc.Move (transform.forward *v * moveSpeed * Time.deltaTime);
transform.Rotate (0f, h * turnSpeed * Time.deltaTime, 0f);
// Local 좌표축과 글로벌 좌표가 달라서....
}
}
'Unity' 카테고리의 다른 글
쉐이더 (0) | 2014.08.04 |
---|---|
중력을 추가 Physics.gravity.y (0) | 2014.08.04 |
C# Input.GetAxis ("Vertical") 와 transform.Rotate() (0) | 2014.08.04 |
C# IInput.GetAxis ("Horizontal")와 transform.Translate() (0) | 2014.08.04 |
C# 회전 (0) | 2014.08.04 |