void MoveCamera() { //================================================================= //カメラ移動処理 //================================================================= Transform _playerTrf = player.transform; camDeg = Mathf.Repeat(iController.GetCameraHorizontal() + camDeg, 360F); Vector3 _vec = new Vector3(0F, camDeg, 0F); this.transform.eulerAngles = _vec; this.transform.position = _playerTrf.position + this.transform.forward * camDist // 後ろ + this.transform.up * camHeight; // 高さ this.transform.LookAt(_playerTrf, Vector3.up); //================================================================= // キャラクターとカメラの間に障害物があったら障害物の位置にカメラを移動させる //================================================================= RaycastHit hit; if (Physics.Linecast(_playerTrf.position, this.transform.position, out hit, targetLayerMask)) { this.transform.position = hit.point; } }