###前提・実現したいこと
カメラをXキーを押すとモデルの周りをまわるようにしたい。
###発生している問題・エラーメッセージ
Xキーを押すと、モデルの周りを回らずにカメラ自身が回ってしまう。
RotateAroundを使っています。
###該当のソースコード
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class FollowCamera : MonoBehaviour { 6 7 public Transform target; //モデルのオブジェクトをセット 8 private Vector3 offset; 9 public float speedX;//100を代入 10 11 // Use this for initialization 12 void Start () { 13 offset = GetComponent<Transform> ().position - target.position; 14 } 15 16 // Update is called once per frame 17 void LateUpdate () { 18 GetComponent<Transform> ().position = target.position+offset; 19 if (Input.GetKey (KeyCode.X)) { 20 transform.RotateAround (target.position,Vector3.up,Time.deltaTime * speedX); 21 } 22 } 23} 24
他に必要な情報があれば追記していきますので、どうかお願いします。
###補足情報(言語/FW/ツール等のバージョンなど)
Unity5.6.1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。