1、需要控制沿Y轴旋转的物体,如下所示:
2、编写控制该物体旋转的脚本,如下所示:
using UnityEngine;
using System.Collections;
public class Test_CycleRoate : MonoBehaviour
{
public int rotateAngle=90; //旋转角度
public int rotateSpeed=2; //旋转速度
private bool isOpen=false; //打开排风门
private bool isClose=false; //关闭进风门
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if(isOpen)
{
RotateXOpen(rotateAngle);
}
if(isClose&&isOpen==false)
{
RotateXClose();
}
}
/// <summary>
/// 打开进风门
/// </summary>
public void OpenEnterWindDoor()