「Player」という名前のC#スクリプトを作成して以下のスクリプトをコピペして保存します。そしてインスペクター内にある「Main Camera」にアタッチすれば、FPS視点のような動きができます。
[ スクリプト ]
WASDで移動、Spaceで上昇、Ctrlで下降、Rで原点に戻れます。
using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public class Player : MonoBehaviour { private float RotateSpeed = 1.5f; private float MoveSpeed = 10.0f; private Vector3 Pos_Camera = Vector2.zero; private Vector3 Rot_Camera = Vector2.zero; private void Start() { UnityEngine.Cursor.visible = false; UnityEngine.Cursor.lockState = CursorLockMode.Locked; } private void Update() { #region Reset if(Input.GetKey(KeyCode.R)) { Pos_Camera = Vector3.zero; Rot_Camera = Vector2.zero; } #endregion #region Pos if(Input.GetKey(KeyCode.W)) { Pos_Camera += transform.forward * MoveSpeed * Time.deltaTime; } if(Input.GetKey(KeyCode.S)) { Pos_Camera -= transform.forward * MoveSpeed * Time.deltaTime; } if(Input.GetKey(KeyCode.D)) { Pos_Camera += transform.right * MoveSpeed * Time.deltaTime; } if(Input.GetKey(KeyCode.A)) { Pos_Camera -= transform.right * MoveSpeed * Time.deltaTime; } if(Input.GetKey(KeyCode.Space)) { Pos_Camera += Vector3.up * MoveSpeed * Time.deltaTime; } if(Input.GetKey(KeyCode.LeftControl)) { Pos_Camera -= Vector3.up * MoveSpeed * Time.deltaTime; } transform.position = Pos_Camera; #endregion #region Rot Rot_Camera.x -= Input.GetAxis("Mouse Y") * RotateSpeed; Rot_Camera.x = Math.Clamp(Rot_Camera.x, -90, 90); Rot_Camera.y += Input.GetAxis("Mouse X") * RotateSpeed; transform.rotation = Quaternion.Euler(Rot_Camera.x, Rot_Camera.y, 0); #endregion } }