ポジションは変わらずに、その場所を中心にカメラを回転させる
GameObjectの中にカメラを配置
以下のスクリプトでGameObject自体を回転させる
CameraAxis.cs
using UnityEngine;
using System.Collections;
public class CameraAxis : MonoBehaviour
{
public float fRotateSpeed = 10.0f;
void Update()
{
// 左
bool canRotateLeft = Input.GetMouseButton(0);
// 右
bool canRotateRight = Input.GetMouseButton(1);
// 中
bool canResetPos = Input.GetMouseButton(2);
if (canRotateLeft)
{
// 移動量
float fValue = fRotateSpeed * Time.deltaTime;
// 回転
transform.Rotate(0, -fValue, 0, Space.World);
}
if (canRotateRight)
{
float fValue = fRotateSpeed * Time.deltaTime;
transform.Rotate(0, fValue, 0, Space.World);
}
if (canResetPos)
{
transform.localRotation = Quaternion.identity;
}
}
}
参考
079 GameObjectを中心にカメラを回転させる
Unityでマウス入力を扱う
Unityメモ – Transformにリセット処理を追加してみる