個別に砲塔の角度を変えられるようにする


個別に砲塔の角度を変える
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TurretController : MonoBehaviour
{
    public string playerName;
    private Vector3 angle;
    private AudioSource audioS;
    void Start()
    {
        angle = transform.eulerAngles;
        audioS = GetComponent<AudioSource>();
    }
    void Update()
    {
        if(Input.GetButton("Up" + playerName))
        {
            audioS.enabled = true;
            angle.x -= 0.5f;
            transform.eulerAngles = new Vector3(angle.x, transform.root.eulerAngles.y, 0);
            // 回転できる角度に制限を加える。
            if (angle.x < 70)
            {
                angle.x = 70;
            }
        }
        else if(Input.GetButton("Down" + playerName))
        {
            audioS.enabled = true;
            angle.x += 0.5f;
            transform.eulerAngles = new Vector3(angle.x, transform.root.eulerAngles.y, 0);
            // 回転できる角度に制限を加える。
            if (angle.x > 90)
            {
                angle.x = 90;
            }
        }
        else
        {
            audioS.enabled = false;
        }
    }
}







個別に砲塔の角度を変える
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TurretController : MonoBehaviour
{
    public string playerName;
    private Vector3 angle;
    private AudioSource audioS;
    void Start()
    {
        angle = transform.eulerAngles;
        audioS = GetComponent<AudioSource>();
    }
    void Update()
    {
        if(Input.GetButton("Up" + playerName))
        {
            audioS.enabled = true;
            angle.x -= 0.5f;
            transform.eulerAngles = new Vector3(angle.x, transform.root.eulerAngles.y, 0);
            // 回転できる角度に制限を加える。
            if (angle.x < 70)
            {
                angle.x = 70;
            }
        }
        else if(Input.GetButton("Down" + playerName))
        {
            audioS.enabled = true;
            angle.x += 0.5f;
            transform.eulerAngles = new Vector3(angle.x, transform.root.eulerAngles.y, 0);
            // 回転できる角度に制限を加える。
            if (angle.x > 90)
            {
                angle.x = 90;
            }
        }
        else
        {
            audioS.enabled = false;
        }
    }
}





個別に砲塔の角度を変えられるようにする