###前提・実現したいこと
まず、Unityでカメラが上下運動(浮いたり落ちたり)するシステムを作っています。
そして、このカメラを親に、その少し下の座標に子オブジェクト(パーティクル)を作っています。
カメラにMouseLookスクリプトを付けて、再生時にカーソルの位置で視点が変わるようにしているのですが、
そのせいか、カメラの視点が変わる(回転?)と、子オブジェクトも回転してしまうのか、
下にある子オブジェクトが見えなくなってしまいます。
**上下運動には連動しても、回転はしない(常にカメラの下方)方法**はないでしょうか。
どうぞよろしくお願いします。
また、MouseLookスクリプトはこのようになっています。
C#
1using UnityEngine; 2using System.Collections; 3 4[AddComponentMenu("Camera-Control/Mouse Look")] 5public class MouseLook : MonoBehaviour { 6 7 public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 } 8 public RotationAxes axes = RotationAxes.MouseXAndY; 9 public float sensitivityX = 15F; 10 public float sensitivityY = 15F; 11 12 public float minimumX = -360F; 13 public float maximumX = 360F; 14 15 public float minimumY = -60F; 16 public float maximumY = 60F; 17 18 float rotationY = 0F; 19 20 void Update () 21 { 22 if (axes == RotationAxes.MouseXAndY) 23 { 24 float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX; 25 26 rotationY += Input.GetAxis("Mouse Y") * sensitivityY; 27 rotationY = Mathf.Clamp (rotationY, minimumY, maximumY); 28 29 transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0); 30 } 31 else if (axes == RotationAxes.MouseX) 32 { 33 transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0); 34 } 35 else 36 { 37 rotationY += Input.GetAxis("Mouse Y") * sensitivityY; 38 rotationY = Mathf.Clamp (rotationY, minimumY, maximumY); 39 40 transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0); 41 } 42 } 43 44 void Start () 45 { 46 // Make the rigid body not change rotation 47 if (GetComponent<Rigidbody>()) 48 GetComponent<Rigidbody>().freezeRotation = true; 49 } 50}

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/12/22 11:46