Unity
C# 회전
코드버무려
2014. 8. 4. 15:51
유니티에서 방향키를 누르면 회전하면서 이동한다.
using UnityEngine;
using System.Collections;
public class Move : MonoBehaviour {
public float moveSpeed;
public float turnSpeed = 90f; // 90도
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float h = Input.GetAxis ("Horizontal");
float v = Input.GetAxis ("Vertical");
transform.Translate (new Vector3 (h, v, 0f) * moveSpeed * Time.deltaTime);
transform.Rotate(0f, turnSpeed * Time.deltaTime, 0f);
}
}