こんにちは。
エラーが出たわけではなく、動きがおかしいというだけなのですが、
using System.Collections; using System.Collections.Generic; using UnityEngine; /// <summary> /// このスクリプトはRigidbodyを付けたプレイヤーにアタッチしてください。 /// </summary> public class GazeMotion : MonoBehaviour { float mouseX; float mouseY; Rigidbody rb; Camera _MainCamera; float _MainCameraX = 0; [SerializeField, Range(1, 11)] private float rotateSpeed = 5; [SerializeField, Range(0, 45f)] private float rotateDownerLimit = 45f; [SerializeField, Range(0, -45f)] private float rotateUpeerLimit = -45f; void Start() { rb = GetComponent<Rigidbody>(); _MainCamera = Camera.main; } void Update() { mouseX = Input.GetAxis("Mouse X"); mouseY = Input.GetAxis("Mouse Y"); rb.transform.Rotate(transform.rotation.x, mouseX * rotateSpeed, 0); _MainCamera = Camera.main; CameraRotate(); } void CameraRotate() { if (mouseY == 0) { return; } float _XRotate = mouseY * rotateSpeed; float _PredictionX = _MainCamera.transform.rotation.x + _XRotate; Debug.Log(_PredictionX); Quaternion y = Quaternion.Euler(Mathf.Clamp(-_PredictionX, rotateUpeerLimit, rotateDownerLimit), rb.transform.localRotation.eulerAngles.y, 0); _MainCamera.transform.rotation = y; } }
こちらのスクリプトを使って、FPSカメラを作ろうとしたのですが、出来ません。正確に言うと、rotationのXがなんかガタガタします。助けてくださいお願いします
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/07 14:07
2019/03/08 09:30
2019/03/08 09:31 編集
2019/03/09 07:04