About
Contents
STL
Android
Eigen
enchant.js
Firefox OS
OpenGL
OpenGL ES 2.0
pukiwiki
UE4
Unity
Windows Phone
Xamarin
Materials Link
その他
PR
STL
Android
Eigen
enchant.js
Firefox OS
OpenGL
OpenGL ES 2.0
pukiwiki
UE4
Unity
Windows Phone
Xamarin
以前のリビジョンの文書です
カメラの向きに合わせてGameObjectを操作します。 TransformDirectionを使えばGameObjectの方向ベクトルが取得できます。
using UnityEngine; using System.Collections; public class PlayerScript : MonoBehaviour { CharacterController controller; Vector3 moveDirection; float fSpeed = 3.0f; void Start () { controller = GetComponent("CharacterController") as CharacterController; } void Update () { Vector3 forward = Camera.mainCamera.transform.TransformDirection( Vector3.forward ); Vector3 right = Camera.mainCamera.transform.TransformDirection( Vector3.right ); moveDirection = Input.GetAxis("Horizontal") * right + Input.GetAxis("Vertical") * forward; moveDirection *= fSpeed; // 移動 controller.Move( moveDirection * Time.deltaTime ); } }