041 カメラの向きに合わせてGameObjectを回転させる
概要
using UnityEngine;
using System.Collections;
public class SphereScript : MonoBehaviour
{
float fSpeed = 50.0f;
void Update ()
{
Vector3 forward = Camera.mainCamera.transform.TransformDirection( Vector3.forward );
Vector3 left = Camera.mainCamera.transform.TransformDirection( Vector3.left );
Vector3 moveDirection = Input.GetAxis("Horizontal") * forward + Input.GetAxis("Vertical") * left;
transform.Rotate( (moveDirection * fSpeed * Time.deltaTime), Space.World );
}
}