一人称視点のカメラを作る(FPS)
















FPSモードで砲塔の角度を変える
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HeadController : MonoBehaviour
{
// ★砲塔の角度
public GameObject turret;
void Update()
{
transform.rotation = Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0);
// ★砲塔の角度
turret.transform.rotation = Quaternion.Euler(Camera.main.transform.eulerAngles.x, transform.eulerAngles.y, 0);
}
}

















FPSモードで砲塔の角度を変える
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HeadController : MonoBehaviour
{
// ★砲塔の角度
public GameObject turret;
void Update()
{
transform.rotation = Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0);
// ★砲塔の角度
turret.transform.rotation = Quaternion.Euler(Camera.main.transform.eulerAngles.x, transform.eulerAngles.y, 0);
}
}

一人称視点のカメラを作る(FPS)