Unity

C# Input.GetAxis ("Vertical") 와 transform.Rotate()

코드버무려 2014. 8. 4. 16:22

using UnityEngine;

using System.Collections;


public class Move2 : MonoBehaviour {


public float moveSpeed = 5f;

public float turnSpeed = 180f;


// 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 (0f, 0f, v * moveSpeed * Time.deltaTime));

transform.Rotate (0f, h * turnSpeed * Time.deltaTime, 0f);

}

}